Skip to the workspace
Pebellslearn by building
Projects and Apps  ›  Lesson

Projects and Apps

Projects & Apps 14 minA Django project is the whole site with its settings, while an app is a self-contained feature package inside it, created with startapp and switched on in INSTALLED_APPS.

django / Projects and Apps

Explore each scene at your own pace.

01 · The rule

The rule

Projects and Apps

Django uses two words that sound alike and mean different things. The project is the whole cookbook website. An app is one feature inside it, such as recipes. Keep them straight and every folder in a Django codebase makes sense.

The rule

One project per site; one app per feature.

With the environment active, create the project. The final dot means "put it in the current folder":

django-admin startproject cookbook .
cookbook/            <- the folder you made earlier
├── manage.py        <- the command tool for this project
└── cookbook/        <- the project's Python package
    ├── __init__.py
    ├── settings.py  <- configuration for the whole site
    ├── urls.py      <- the site's root table of URLs
    ├── asgi.py      <- entry point for async servers
    └── wsgi.py      <- entry point for classic servers

Now create an app for the first feature:

python manage.py startapp recipes
recipes/
├── __init__.py
├── admin.py       <- show models in the admin site
├── apps.py        <- the app's configuration class
├── migrations/    <- database change history
├── models.py      <- data
├── tests.py       <- tests
└── views.py       <- request handlers

An app does nothing until you switch it on in settings.py:

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    # ...the other built-in apps...
    "recipes",
]

Notice that the built-in admin and login system are apps too. Django itself is assembled the same way you will build the cookbook.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.