[Django]-Django 1.9: Should I avoid importing models during `django.setup()`?

13πŸ‘

βœ…

Should I import my models in the __init__.py of my django apps ?

No, you must not import any model in the __init__.py file of any installed app. This is no longer possible in 1.9.

From the release notes:

All models need to be defined inside an installed application or
declare an explicit app_label. Furthermore, it isn’t possible to
import them before their application is loaded. In particular, it
isn’t possible to import models inside the root package of an
application.

πŸ‘€knbk

Leave a comment