On Thu, Mar 3, 2016 at 3:28 PM, Andres Osinski <andres.osinski@gmail.com> wrote:
Hi everyone! I'm having an issue with circular imports in Django 1.9 that I have not seen in my app, which had been running 1.7 before.I have a Django app in apps.common, which has its associated apps.common.models too. No imports on __init__.py or anything of the sort.When I my app in apps.account.models attempts to import apps.common.models, it complains that said module does not exist.Putting a pdb set_trace() call at the top of apps.common.models and apps.account.models shows that the former executes *before* apps.account.models, so I fail to see how this could result in the posted error.For the record, both apps use the new AppConfig scheme in their corresponding apps.py file, and the import order in INSTALLED_APPS is:'apps.common.CommonConfig','apps.account.AccountConfig',...Has anyone else had a similar issue in this upgrade? Is there anything I can do to diagnose the source of this?
Are you bringing in other functions in as part of your imports, or just other models? If you are only bringing in models for use with FK's and M2M's, then I would suggest referring to those models via their text path rather than using the Python class object directly. It avoids needing the import statement during the initial load (which avoids the circular import issue). See the end of this section about referring to models in other applications using a string rather than the real Python object (and make sure to remove the related import statements):
-James
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUWHXr6axqA5drrsMnR3%2B9d0D1wBHSK9wQwSmqs52xFAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment