Django imports models for apps that aren't enabled?

18 views
Skip to first unread message

Stodge

unread,
Jan 5, 2016, 10:57:51 AM1/5/16
to Django users
I'm using Django 1.6.9. When the dev server (and hence Apache) starts, is Django supposed to import models for apps that exist on disk, but aren't enabled in the settings? I'm seeing this behaviour and I wasn't expecting it. Thanks

Carl Meyer

unread,
Jan 5, 2016, 11:02:24 AM1/5/16
to django...@googlegroups.com
Hi Stodge,
Django shouldn't do that on its own. AFAIK the only reason a models file
should be imported is a) because it's listed in INSTALLED_APPS, or b)
because something else that is imported imports it (possibly also c) an
installed model has an FK linking to it with a string reference?).

My first guess would be that you're seeing case (b). If you just add an
"assert False" at module-level in the models file in question, the
resulting traceback should show you the import chain leading to its import.

Carl

signature.asc

Stodge

unread,
Jan 5, 2016, 11:15:30 AM1/5/16
to Django users
Carl, thanks. You were right - I was experiencing "b".

Thanks again
Mike
Reply all
Reply to author
Forward
0 new messages