manage.py Cheat Sheet

Cheat Sheet covering Django's manage.py

Download as .pdf

API: /api/v1/cheatsheet/managepy-cheat-sheet

General syntax:

bash

1
python manage.py <command>

Project Setup

Create migrations

bash

1
python manage.py makemigrations

Generate migration files based on model changes.

Apply migrations

bash

1
python manage.py migrate

Apply migrations to the database.

Show migration status

bash

1
python manage.py showmigrations

See applied and pending migrations.

Development Server

Start server

bash

1
python manage.py runserver

Default: http://127.0.0.1:8000/

Start on custom port

bash

1
python manage.py runserver 8080

Runs development server on port 8080

Expose to local network

bash

1
python manage.py runserver 0.0.0.0:8000

Apps

Create new app

bash

1
python manage.py startapp blog

Creates Django app structure.

Users / Admin

Create superuser

bash

1
python manage.py createsuperuser

Used for Django admin access.

Change password

bash

1
python manage.py changepassword username

Shell / Debugging

Open Django shell

bash

1
python manage.py shell

Useful for testing models and queries.

Example:

bash

1
python manage.py shell

Inside shell:

python

1
2
from blog.models import BlogPostModel
BlogPostModel.objects.all()

Static Files

Collect static files (production)

bash

1
python manage.py collectstatic

Copies static files into one target directory.

Testing

Run all tests

bash

1
python manage.py test

Run specific app tests

bash

1
python manage.py test blog

Database Utilities

SQL for migrations

bash

1
python manage.py sqlmigrate blog 0001

Flush database

bash

1
python manage.py flush

Deletes data, keeps schema.

Useful Flags

Specify settings file

bash

1
python manage.py runserver --settings=main.settings.prod

Verbose output

bash

1
python manage.py migrate --verbosity 2

Common Workflow

bash

1
2
3
4
5
python manage.py startapp blog
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Join the Newsletter

Practical insights on Django, backend systems, deployment, architecture, and real-world development — delivered without noise.

Get updates when new guides, learning paths, cheat sheets, and field notes are published.

No spam. Unsubscribe anytime.



There is no third-party involved so don't worry - we won't share your details with anyone.