I know this might sound stupid but I was just wondering what's the difference if I just type 'myapp' instead of 'myapp.apps.myappConfig' in my Installed Apps list. Is it something related to models or what?
Regards
If you use myapp.apps.myappConfig
, then you are explicitly telling Django to use that app config class.
Changing the app config class lets you change the behaviour of the application, for example, when you use the admin app, you can use django.contrib.admin.apps.AdminConfig
which autodiscovers apps, or django.contrib.admin.apps.SimpleAdminConfig
, which does not.
If you just use myapp
, then Django will try to use default_app_config
. If that isn't set, then it will use the default AppConfig
.
A lot of the time, there isn't any customisation in myappConfig
, or default_app_config
is set, so you'll get the same behaviour whichever style you use in INSTALLED_APPS
.
Ever since AppConfig
was added in Django 1.7, the recommendation has been to use ``myapp.apps.myappConfigbecause it's explicit, and avoid using
default_app_config`.
However, in practice, it seems that users have preferred the simplicity of using myapp
. Therefore, there's an open pull request which will remove default_app_config
, and automatically select the app config class when there is only one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With