﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15084	Unnecessary imports lead to ImportError	Klaas van Schelven	nobody	"django/utils/translation/trans_real.py contains 

{{{
         for appname in settings.INSTALLED_APPS:
            app = import_module(appname)
            apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
}}}

As you can see, the only reason apps are imported here is to determine their location so a locale path can be tucked on. However, importing apps comes at a cost. There are cases in which this import leads to a circular reference, leading to the inability of the application to load.

There may be more locations where this particular loop over INSTALLED_APPS leads to problems, though I have not encountered them.

On a somewhat related note, I don't think Django provides us with an easy way to loop over the installed apps. We have models.get_apps, but that doesn't work for modelless apps. This might lead to issues such as the one I reported here:
https://github.com/jezdez/django-staticfiles/issues#issue/2

I'll try to reproduce the negative consequences (the ImportError) in a few moments and post the results here. I also have some kind of patch for this running in production, but I can imagine it's not really core-proof. Evaluation is appreciated."	Bug	closed	Internationalization	1.4	Normal	fixed		klaasvanschelven@…	Accepted	1	1	1	0	0	0
