Understanding Django’s Apps and AppConfig
Introduction
A Django project is a collection of apps that work together to deliver a set of functions. This collection consists of apps provided by Django, ourselves and other developers. In a project, the full set of apps belonging to a project is found in the projects settings.py
, declared as the INSTALLED_APPS
variable.
Apps and AppConfig creation
When the application server starts (django-dev server or uwsgi
server), it loads the settings defined for the project to configure the site. The variable DJANGO_SETTINGS_MODULE
defines the correct settings for the environment where your app is running i-e development or production. The loading process involves the loading of the URL configurations defined by each app and creating the URL tree structure. But before it does this and any of the other settings
tasks, it needs to know about all the apps in the project. Hence as part of loading the project settings, the application server takes the INSTALLED_APPS
and loads or generates an AppConfig
object for each app. This collection of AppConfig
objects are then stored in an instance of theApps
class. This instance of the Apps
class is called the master registry. This master registry is the registry for the entire Django project that is being run by this application server.