Skip to the workspace
Pebellslearn by building
Projects and Apps  ›  Capstone Project

Running Your Project

Running your Project 12 minpython manage.py runserver starts Django's development server, which reloads on code changes and is meant only for building the site on your own machine.

django / Running Your Project

Explore each scene at your own pace.

01 · The rule

The rule

Running Your Project

Everything so far has been files. Now the cookbook comes alive. One command starts a small web server on your own machine, and you can watch every change you make appear in the browser a moment later.

The rule

runserver is for building, never for hosting.

From the folder that holds manage.py, with the environment active:

python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly
until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

Django version 5.2.6, using settings 'cookbook.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

WARNING: This is a development server. Do not use it in a production setting.

Open http://127.0.0.1:8000/ and you get Django's welcome page with a rocket. The exact number of migrations may differ; the message is what matters.

Read the output like this:

  • Unapplied migrations: the built-in apps (admin, auth, sessions) need tables that do not exist yet. Stop the server and run python manage.py migrate once; the warning goes away and db.sqlite3 now holds those tables.
  • 127.0.0.1:8000: the server listens only on your own machine, on port 8000.
  • Control-C stops it.

Useful variations:

python manage.py runserver 8080          # another port
python manage.py runserver 0.0.0.0:8000  # reachable from other devices on your network

(For the second, add your computer's address to ALLOWED_HOSTS.)

The development server reloads itself when you save a Python file, so you rarely restart it. But it is built for convenience, not for crowds: it has not been through the security audits or performance work a public server needs. Real deployments run Django behind a production server such as Gunicorn (WSGI) or Uvicorn (ASGI), which use the wsgi.py and asgi.py files startproject made.

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