Closed vladyslav2 closed 5 years ago
The error may appear if you are using emencia models in your models, because of circle dependencies/imports. To workaround the problem, avoid direct using emencia models in relations (use strings to refer emencia models instead of classes), and do import from emencia immediately before using classes in methods and functions, instead of importing them at the start of the module.
Can you tell me whats wrong with import ? Why use strings to refer is better that import ?
Any django management command is executing in the python environment hooked by the django core, which imports all project applications and particularly - 'models.py' modules from each application.
In case of circle dependencies between models.py modules, module A imports module B, then B wants to import A, which is already starting import and so - is just returning as is, i.e. just constructed, without classes declared inside it.
I don't know why, but using emencia models in your application model causes circle dependencies, and so - import error.
Using strings in relation declarations helps to avoid circle dependencies problems - you don't need to import models before declaring relations.
I don't know why, but using emencia models in your application model causes circle dependencies, and so - import error.
i use emencia as other users i belive :)
And i can't understand how does your answer connected to init.py or maybe you don't understand me ?
If you mean init.py module - it is already present in correspondent folders. If you mean django internal init.py module where the exception has appeared
Oh, the init.py files are already added in the current version.
Just: pip uninstall emencia.django.newsletter pip install -e git://github.com/Fantomas42/emencia-django-newsletter.git#egg=emencia.django.newsletter
Ubuntu 11.10 Python 2.7.2+
vladka@sonic:~/PycharmProjects/divyaradio$ ./manage.py send_newsletter Unknown command: 'send_newsletter' Type 'manage.py help' for usage.
in django/core/management/init.py:
50 try: 51 f, path, descr = imp.find_module(part,path) 52 except ImportError,e: 53 if os.path.basename(os.getcwd()) != part: 54 print e 55 raise e
print e show this message - No module named emencia
i think you'll have to add empty init.py file in emencia and in emincia/django directory.
And Thank you for you application!