Register apps by package name vs dotted path in Django
March 23, 2021 ‐ 1 min read
When you create a new app in Django with
python manage.py startapp <app name> you need to register it by adding it to the
INSTALLED_APPS in the
settings.py file. I often forget the last step :).
You can add an app in two ways to
INSTALLED_APPS, either by adding the package name or the dotted path to a subclass of
AppConfig. According to the Django docs the latter is preferred.
The following shows both ways of registering a Django app.
INSTALLED_APPS = [ # ... 'blog', 'posts.apps.PostsConfig', ]
So what is the difference between the two? The latter option, with dotted path, allows you to add configuration options to your app. For example, you can override the
ready method where you can registering signals. The first, just the package name, will use the configuration from the class
django.apps.AppConfig. You might not need to change the app config right away but using the dotted path allows you to be more flexible in the future.