|Order of INSTALLED_APPS||Stefano Crosta||8/12/13 4:34 AM|
There is one situation where the order of INSTALLED_APPS really matters - which is template override.
One typical case is grappelli - see https://django-grappelli.readthedocs.org/en/2.4.5/quickstart.html#setup
Though not officially documented (?) I've found references in the mailing list to the fact that APPS coming first in the INSTALLED_APPS will have priority - their templates will be loaded effectivily overriding/shadowing lower priority app ones.
Now, if this is "officially" confirmed in my opinion it would require:
If it's not, well... maybe another mechanism should be implemented. For very specific cases I've been using https://pypi.python.org/pypi/django-apptemplates/ which syntax looks very clean and clear to me. I'm not sure if there are other drawbacks or if this would be worth including natively into django rather then leaving it as an (abandoned) external app...
|Re: Order of INSTALLED_APPS||Aymeric Augustin||8/12/13 5:59 AM|
2013/8/12 Stefano Crosta <stefano...@gmail.com>
There are at least two other similar cases: translations and static files.
Yes, we should standardize and document that.
On a related note, some lookups depend on the INSTALLED_APPS settings and others depend on the list of applications registered in the AppCache. The latter may be a superset of the former. We should give some thought to this problem before committing to a given discovery behavior.
Eventually, Django should probably raise an error when the AppCache loads a model from an application than isn't in INSTALLED_APPS. But there may be uses cases for this eg. dynamically generated models. Enough said, I'm stopping this digression here :)
The default generated settings file defines INSTALLED_APPS a tuple, not a set.
We could change it to a list, however, that will introduce inconsistencies with other settings where the default value is a tuple and can't be changed without introducing backwards incompatibilities.
|Re: Order of INSTALLED_APPS||Ramiro Morales||8/12/13 6:41 AM|
On Mon, Aug 12, 2013 at 9:59 AM, Aymeric AugustinFor translations, we have such documentation already:
|Re: Order of INSTALLED_APPS||Florian Apolloner||8/12/13 11:29 AM|
On Monday, August 12, 2013 3:41:15 PM UTC+2, Ramiro Morales wrote:For translations, we have such documentation already:
For templates too: https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.app_directories.Loader -- but I agree it's somewhat hidden ;)
|Re: Order of INSTALLED_APPS||Stefano Crosta||8/13/13 3:09 AM|
Aymeric, Ramiro, Florian,
thanks a lot for your answers!
Indeed there is some (slightly hidden :D ) documentation!
And it has improved since 1.5, I now see! - I remembered reading something before, but I couldn't find them anymore when I wrote yesterday's message.
My proposal would then be to simply add another box to the https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps to say "order matters" once more and link the other two pages for translations and templates.
*if you think this would* help I could do it as well as a ticket. To save everybody's time no answer will mean it's not worth it!
(PS. Also please fully disregard my momentary lapse of reason concerning `sets` in the settings - I don't know what got into me)
|Re: Order of INSTALLED_APPS||Aymeric Augustin||8/13/13 3:20 AM|
2013/8/13 Stefano Crosta <stefano...@gmail.com>
Yes, please file one, and include a link to this discussion.
|Re: Order of INSTALLED_APPS||Stefano Crosta||8/14/13 2:26 AM|
|Re: Order of INSTALLED_APPS||Kevin Christopher Henry||9/1/13 1:31 PM|
Sorry to be late to this thread, I just came across it.
There's another place where the order of INSTALLED_APPS matters: management commands. Management commands associated with apps that come later in INSTALLED_APPS will replace those with the same name that are listed earlier. I can't find this documented anywhere, but a look at the code confirms it. South, for example, takes advantage of this to override the syncdb command (and hints at the ordering issue when the documentation says: "add 'south' to the end of INSTALLED_APPS").
So a documentation update should probably note this specifically in the management documentation, as well as mentioning it in the box for INSTALLED_APPS. (I also think static files should also be mentioned in the box, since as Aymeric points out that is another area dependent on the order of apps.)
One thing that's unfortunate is that the semantics of ordering for management commands is opposite that of the other cases. For templates, static files, and translations, listing an app first gives it precedence, whereas with management commands it's listing it last. Ideally this would be changed so that management commands were consistent with the other cases, but that would create serious backwards compatibility issues. Like, breaking everyone's South installation. :-O
|Re: Order of INSTALLED_APPS||Marc Tamlyn||9/1/13 3:04 PM|
I don't think it would break South installations as custom app commands will always override builtins. Could you open a ticket for that? The inconsistency is problematic. Obviously it would be backwards incompatible, but we need to gauge the size of the impact.
|unk...@googlegroups.com||9/1/13 7:22 PM||<This message has been deleted.>|
|Re: Order of INSTALLED_APPS||VernonCole||9/2/13 2:34 AM|
It also affects _how_ South works, not just _whether_ it works. Only this week I had to install a patch for the formhub package which consisted of re-ordering INSTALLED_APPS so that tables were built in the correct order on PostgreSQL installations.
|Re: Order of INSTALLED_APPS||Shai Berger||9/2/13 3:22 AM|
On Monday 02 September 2013 12:34:03 VernonCole wrote:This is getting off-topic for this list -- but South has a concept of
dependencies between migrations, which is the right way to get migrations in
the right order. You shouldn't depend on INSTALLED_APPS order for that.
Unless I'm missing something, in which case, let's take it to the South list.
|Re: Order of INSTALLED_APPS||German Larrain||9/9/13 3:32 PM|
A related question: What about repeated entries of apps in INSTALLED_APPS? I remember seeing this once and, if I recall correctly, no errors were raised. I guess ImproperlyConfigured would be a suitable exception.
|Re: Order of INSTALLED_APPS||Tim Graham||9/10/13 5:02 AM|
Yes, here's the ticket to add validation for INSTALLED_APPS: https://code.djangoproject.com/ticket/12288