Appconfig And The App Registry

What AppConfig is, how Django registers apps, ready() hooks, auto-discovery, and where to place startup code without side effects.

1. Introduction

Every Django app has a configuration class called AppConfig. It tells Django the app's name, label, and how to initialize it at startup. When Django starts, it reads INSTALLED_APPS and loads each app through its AppConfig.

Most of the time Django handles this automatically and you do not need to touch it. But understanding how it works helps when you need to run startup code, customize app labels, or debug app loading issues.

  • You should already have myproject set up with the pages app created and registered.
  • Your .venv must be active and Django 5.2 installed.

2. What is AppConfig

When you create an app with python manage.py startapp pages, Django generates an apps.py file inside the app folder. Open pages/apps.py and you will see:

# pages/apps.py

from django.apps import AppConfig


class PagesConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'pages'

This is the AppConfig class for the pages app. It has two attributes by default:

  • name — the full Python path to the app. Must match the app folder name exactly.
  • default_auto_field — the default field type for auto-generated primary keys. BigAutoField uses a 64-bit integer, which is the Django 5.x default.

3. The app registry

The app registry is Django's internal list of all installed apps. When Django starts, it goes through INSTALLED_APPS, loads each app's AppConfig, and registers it in the registry.

You can inspect the registry from the Django shell:

python manage.py shell
>>> from django.apps import apps
>>> apps.get_app_config('pages')


>>> apps.get_model('pages', 'Page')


>>> [app.name for app in apps.get_app_configs()]
['django.contrib.admin', 'django.contrib.auth', ..., 'pages']

The registry gives Django a single source of truth for all apps, their models, and their configuration. It is what makes features like migrations, admin auto-discovery, and template loaders work automatically.

4. Registering AppConfig in INSTALLED_APPS

There are two ways to register an app in INSTALLED_APPS. Both work, but the second is more explicit and recommended for larger projects.

Short form — just the app name

INSTALLED_APPS = [
    ...
    'pages',
]

Django finds PagesConfig automatically by looking at the default_app_config or the AppConfig class inside apps.py.

Full form — the AppConfig dotted path

INSTALLED_APPS = [
    ...
    'pages.apps.PagesConfig',
]

This is explicit — you are pointing directly to the AppConfig class. Use this form when your app has a custom AppConfig with extra configuration so there is no ambiguity.

5. The ready() hook

AppConfig has a special method called ready(). Django calls it once after all apps have been loaded and the registry is fully populated. It is the correct place to run startup code — for example, connecting signals.

# pages/apps.py

from django.apps import AppConfig


class PagesConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'pages'

    def ready(self):
        import pages.signals  # connect signal receivers on startup

6. Custom app labels

By default, Django uses the app folder name as the app label. The label is used in migration file names, model references, and the admin. If two apps have the same name — for example you install a third party app that clashes with one of yours — you can set a custom label:

# pages/apps.py

from django.apps import AppConfig


class PagesConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'pages'
    label = 'site_pages'  # custom label to avoid conflicts
    verbose_name = 'Site Pages'  # human-readable name shown in admin

verbose_name is what appears in the Django admin panel as the app's display name. It has no effect on how the app works internally.

7. Next steps

You now understand how Django registers and initializes apps through AppConfig. The next step is a deeper look at INSTALLED_APPS — what goes in it, how Django uses it, and common mistakes when adding or removing apps.


Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.