In the Django documentation, a line reads:
New applications should avoid default_app_config. Instead they should require the dotted path to the appropriate AppConfig subclass to be configured explicitly in INSTALLED_APPS.
This suggests I should require users of my app (let's call it sports
) to use the following string in their INSTALLED_APPS
list:
"sports.apps.SportsConfig"
However, all of the Django apps I use (django-rest-framework, django-cors-headers, django-celery-results) use default_app_config
and only require me to specify the first part of the string (in my case "sports"
).
So how should I write my app? (1) Follow the advice in the docs and force users to write the entire string "sports.apps.SportsConfig"
or (2) Follow what all of the other apps in the Django universe are doing and allow users to write only the first part of the string "sports"
.
The difference between a project and app is, a project is a collection of configuration files and apps whereas the app is a web application which is written to perform business logic.
The AppConfig class used to configure the application has a path class attribute, which is the absolute directory path Django will use as the single base path for the application.
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged. So, 1 and 3 are both valid, but 3 would be the recommended approach.
While you're editing mysite/settings.py , set TIME_ZONE to your time zone. Also, note the INSTALLED_APPS setting at the top of the file. That holds the names of all Django applications that are activated in this Django instance.
I think it completely depends if you want to override custom default values of Class AppConfig
for your app.
My Opinion: It's better to create CustomAppConfig (for eg. sports.apps.SportsConfig
) by inheriting from Class AppConfig only for apps you create in your Django projects. Because you can tune different parameters like name, label, a verbose_name for admin panel.
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