Is there a specific way of adding apps in Django

Viewed 231

I read from a post that Django uses INSTALLED_APPS as a list of all of the places to look for models, management commands, tests, and other utilities.

Say I have an app called blog which I would like to add to INSTALLED_APPS, which of these two is advisable:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog.apps.BlogConfig',
]

OR

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
]

Both method seems to work fine for me as a beginner.

1 Answers

According to the Django documentation: https://docs.djangoproject.com/en/3.1/intro/tutorial02/

You should add installed apps using the first way you have noted in your question:

appname.apps.AppnameConfig

If you open up apps.py for the application in question you will see where AppConfig comes from.

Related