I’m curious if we, the Django community, could do a better job emphasizing proper INSTALLED_APPS structure. As per the docs, the “proper” way is to load local apps at the top and take advantage of AppConfig options, so
books.apps.BooksConfig vs simply
But the majority of books/tutorials/code I see continue to load local/3rd party apps at the bottom and to not use AppConfig. In most cases this still works, which I think is the issue, until it doesn’t.
There’s a lot for newcomers to grok about Django but it seems defaulting newbies to loading at the top vs bottom and using AppConfig is the better approach, even if we they don’t fully understand why, no?
I guess it could be a bit clearer. I can’t seem to easily find any reference to declare apps at the “top” of the list: https://docs.djangoproject.com/en/3.0/ref/applications/
Even here: https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-INSTALLED_APPS there’s no mention of it.
I’m curious - I’ve never used the AppConfig method of configuring apps, and, have always loaded local apps at the bottom.
I understand the reason for placing local apps at the top - allowing you to possibly override default behavior / references of system apps.
But I’m not seeing the value of adding another file to the mix to configure an app. (I’m sure there are situations where it’s needed, I just haven’t run into any.)
Aside from the general principle of “Explicit is better than Implicit”, is there something I’m missing as to why these are encouraged now?
It’s mentioned here, for example, in the polls tutorial “at the top.”
FYI pointing to the
AppConfig, if it’s the only one in the
apps submodule, will no longer need
default_app_config from Django 3.2:
I prefer pointing to
AppConfig as it is more explicit and points to the reason for its existence.
I often don’t think about ordering and indeed most projects I’ve worked on have used the reverse of the recommended order, with local apps at the bottom.
Some docs updates would be good. Mentioning something only in the tutorial is really inaccessible.
Good to know Adam. I figured it was something like this, but wanted to check with everyone before I update my stuff and/or we tweak the docs on the matter.
Glad you’re liking the pod Yes, I actually looked at the updated 2 Scoops and saw they were doing it that way which spurred this question since I’m updating my on books for 3.1. I also had advocated at the bottom with the full appconfig stuff, but 2Scoops doesn’t directly cover it but just has the app name at bottom.
Seems based on this thread and a few discussions with others that the docs might need some tightening once 3.2 comes out as @adamchainz noted. I guess mainly tweaking the Polls tutorial.
It’s kind of a cognitive load question (I’m a psychologist but swung into django dev). Not sure it would make a difference, buuuuut, a consistent message would help newbies