I have seen that there are two ways to add a Django app to the settings
. Assuming the app is app_name
, I've seen the following patters:
app_name
INSTALLED_APPS = [
# other apps
'app_name'
]
app_name.apps.AppNameConfig
INSTALLED_APPS = [
# other apps
'app_name.apps.AppNameConfig'
]
I am wondering if there is any difference between these two patterns or if they are equivalent. I also wonder if there is any preferred way to add an application.
They are somehow equivalent, with the exception that the AppConfig
offer a way to customise app's metadata (and maybe more in the future).
This enables you to "rename" 3rd party apps into something else in your project, so it does not collide with a custom app written by you, for example.
There is no preferred way, but from my experience - make an AppConfig
.
More on this in INSTALLED_APPS and AppConfig docs.