Django Apps Explained
In this page:
Project vs App
A Django *project* is the top-level configuration for your entire website — settings, root URLs, WSGI/ASGI entry points. An *app* is a smaller Python package that implements one piece of functionality, such as a blog or a shopping cart. One project can (and usually does) contain many apps.
Note: A good rule of thumb: if a feature could be reused in a completely different website, it probably deserves its own app.
Example: Project vs App
startproject creates the project (the whole site's config); startapp creates blog/ as one self-contained piece of functionality inside it — that's the literal command-level difference between a project and an app.
django-admin startproject mysite
cd mysite
python manage.py startapp blog
⚠️ Run this command in your terminal.
What Lives Inside an App
Every Django app is a normal Python package (a folder with an __init__.py) that conventionally contains models.py for database tables, views.py for request-handling logic, urls.py for its own routes, and an admin.py for admin registration.
Example: What Lives Inside an App
Every app groups its own models.py (data) and views.py (request-handling) together — this Post model and post_list view both live inside the same blog/ app folder.
# blog/models.py
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=200)
# blog/views.py
from django.shortcuts import render
from .models import Post
def post_list(request):
return render(request, 'blog/post_list.html', {'posts': Post.objects.all()})
{# Django-only code -- models.py/views.py/urls.py/settings.py
snippets, or template markup using Django template tags/variables
-- can't run standalone via Judge0 or the browser preview, since
it needs a real Django project. Only this course's pure-Python
examples (example_lang == 'python', no Django imports) are
actually runnable, so those still get the button below. #}
Apps Are Reusable
Because an app only knows about its own models, views, and templates, the same app can be dropped into a different Django project with minimal changes. This is why many third-party Django packages (django-allauth, django-rest-framework) ship as installable apps.
Example: Apps Are Reusable
Because an app only knows about its own models, views, and templates, the same app can be dropped into a different Django project with minimal changes. This is why many third-party Django packages (django-allauth, django-rest-framework) ship as installable apps.
pip install django-allauth
# django-allauth is itself a Django app you add to INSTALLED_APPS
⚠️ Run this command in your terminal.
- Confusing a Django project with a Django app — a project is the whole website, an app is one reusable feature inside it.
- Cramming every feature of a website into a single giant app instead of splitting concerns into separate apps.
- Forgetting that an app is just a plain Python package until it is registered in INSTALLED_APPS.
- A Django project is the whole website configuration; an app is a self-contained feature module inside it.
- Apps are just Python packages with a conventional set of files (models.py, views.py, urls.py, etc.).
- Splitting a site into apps (blog, shop, accounts) keeps code organized and reusable across projects.
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: