What's a Django App?
A project is the whole website. An app is a modular component that does one thing well. A blog app handles posts. A user app handles profiles. A payment app handles transactions. You get the idea.
This modular approach is what makes Django projects scalable. You can develop, test, and even reuse apps across different projects.
Creating an App
Let's create your first app. The command is straightforward:
python manage.py startapp blog
This generates a blog directory with several files. But Django doesn't know about your app yet โ you need to register it.
Registering in INSTALLED_APPS
Open settings.py and find the INSTALLED_APPS list. Add your new app there:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
Without this step, Django won't recognize your models, templates, or management commands. It's like telling Django "hey, this app exists and I want you to include it."
Try it Yourself โThe App Structure
Inside your app directory, you'll see several files. models.py defines your data. views.py contains your logic. admin.py configures the admin interface. apps.py holds the app configuration.
There's also a migrations folder for database changes and a tests.py file for your tests. This structure keeps everything organized from the start.