Johnny Metz
Johnny Metz

Reputation: 5975

Full config path vs app name in Django INSTALLED_APPS

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".

Upvotes: 8

Views: 1658

Answers (1)

nishit chittora
nishit chittora

Reputation: 1034

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.

Upvotes: 5

Related Questions