Installed_Apps Explained
What goes into INSTALLED_APPS, the role of third party apps, app label naming, migration discovery, and common pitfalls when adding or removing apps.
1. Introduction
INSTALLED_APPS is a list in your settings file that tells Django which apps are active in your project. Django uses it to discover models, run migrations, load template directories, register admin classes, and more.
Getting this list right matters. Missing an app means its models are invisible to Django. Adding an app incorrectly causes errors at startup. This guide covers what goes in the list, how Django uses it, and the mistakes to avoid.
- You should already have
myprojectset up with thepagesapp created. - Your
.venvmust be active and Django 5.2 installed.
2. The default apps
When you create a new Django project, INSTALLED_APPS already contains six built-in apps:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Here is what each one does:
django.contrib.admin— the Django admin panel. Gives you a ready-to-use interface to manage your database records.django.contrib.auth— the authentication system. Provides users, groups, permissions, and password hashing.django.contrib.contenttypes— a framework for working with generic relations between models. Required byauthandadmin.django.contrib.sessions— manages user sessions. Required if you use login/logout or store data between requests.django.contrib.messages— a one-time notification system. Used to show success or error messages after form submissions.django.contrib.staticfiles— manages static files like CSS and JavaScript. Required for thetemplate tag to work.
3. Adding your own apps
Every app you create with python manage.py startapp must be added to INSTALLED_APPS before Django recognizes it. Add your apps below the built-in ones:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# your apps
'pages',
]
You can use either the short form 'pages' or the full AppConfig path 'pages.apps.PagesConfig'. Both work. Use the full path when your app has a custom AppConfig with extra configuration. We covered this in the AppConfig and the App Registry tutorial.
4. Adding third party apps
When you install a third party package with pip — for example django-crispy-forms or djangorestframework — you also need to add it to INSTALLED_APPS. The package documentation always tells you the exact string to use.
A common convention is to group your apps into three sections with comments:
INSTALLED_APPS = [
# Django built-in apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Third party apps
'rest_framework',
'crispy_forms',
# Your apps
'pages',
]
5. How Django uses INSTALLED_APPS
Django reads INSTALLED_APPS at startup and uses it for several things:
- Model discovery — Django finds all
models.pyfiles from apps in this list. If your app is not listed, its models do not exist as far as Django is concerned. - Migrations —
makemigrationsonly generates migrations for apps inINSTALLED_APPS. Missing an app here means its database tables are never created. - Template discovery — when
APP_DIRS: Trueis set inTEMPLATES, Django looks for atemplates/folder inside each app listed here. - Static files — Django collects static files from a
static/folder inside each listed app when you runcollectstatic. - Admin auto-discovery — Django automatically imports
admin.pyfrom each listed app so registered models appear in the admin panel.
6. Common mistakes
Forgetting to add the app after startapp
Running python manage.py startapp pages creates the folder but does not register the app. You must add it to INSTALLED_APPS yourself. The symptom is that makemigrations finds no changes even though you added models.
Wrong app name or path
If the string in INSTALLED_APPS does not match the actual app folder name or the dotted path to the AppConfig class, Django raises an ImproperlyConfigured error at startup.
# Wrong — folder is named 'pages' not 'page'
'page',
# Correct
'pages',
Removing an app without removing its migrations
If you remove an app from INSTALLED_APPS but leave its migration files on disk, Django may raise errors when running migrate. Always clean up migration files when permanently removing an app.
Duplicate entries
Adding the same app twice — once as 'pages' and once as 'pages.apps.PagesConfig' — causes Django to raise an error about duplicate app labels. Use one form consistently.
7. Removing default apps
You can remove built-in apps you do not need, but be careful — some apps depend on others:
- Removing
django.contrib.adminis fine if you do not use the admin panel. - Removing
django.contrib.authmeans no users, groups, or permissions — also removes the admin. - Removing
django.contrib.contenttypesbreaksauthandadmin. - Removing
django.contrib.staticfilesmeansstops working.
8. Next steps
You now have a solid understanding of INSTALLED_APPS and how Django uses it. The next step is to look at project structure best practices — how to organize your apps, templates, static files, and settings as your project grows.