103👍
There is a circular import in your code, that’s why the Item can’t be imported in action.
You can solve the problem by removing the import of a class in one of your files, and replacing it with a string containing the name of the class, as explained in the documentation. For example :
effects = models.ManyToManyField('effects.Effect',through='ItemEffect',blank=True)
31👍
Like madjar suggested, there is likely a circular import in your code. If you’re having trouble finding out where the circle is (which modules and imports are involved), you can use the traceback option to get an idea of where the problem lies:
python manage.py validate --traceback
Edit – Validate is deprecated from django 1.7. So please run the following command –
python manage.py check --traceback
- [Django]-Trying to parse `request.body` from POST in Django
- [Django]-Django: Reference to an outer query may only be used in a subquery
- [Django]-How to specify the login_required redirect url in django?
10👍
This was the first post that came up on Google so I will post this alternative cause of error.
In my code there was no circular imports, I solved this problem by manually deleting all .pyc files in my project. Apparently restarting the application wasn’t recompiling my code.
- [Django]-How to implement FirebaseDB with a Django Web Application
- [Django]-Django template can't see CSS files
- [Django]-What is the easiest way to clear a database from the CLI with manage.py in Django?
10👍
Try to import Locally your model instead of as public one, Example
def sample_function():
from effects.models import Effect # import within function or class
or import model as String -> ‘APP_NAME.MODEL_NAME’
pay_methods = models.ManyToManyField('payment_app.AllowedPayMethod')
- [Django]-Only accept a certain file type in FileField, server-side
- [Django]-PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django
- [Django]-How to update an existing Conda environment with a .yml file
0👍
Similar situation to Pythonator – I had an alternate cause for the same error message.
In my case, I had forgotten to activate the virtual environment I set up for my project and was trying to run the server. After activating the environment and running the server again I had no issues.
- [Django]-Django: Implementing a Form within a generic DetailView
- [Django]-How to use regex in django query
- [Django]-How can I call a custom Django manage.py command directly from a test driver?