Django Cheat Sheet
Transform, format, and optimize your data instantly with this free client-side tool.
Management
Create a new Django project
Create a new Django app
Start the development server
Create an admin user
Open the interactive Python shell
Collect static files into STATIC_ROOT
Migrations
Create new migrations based on model changes
Apply migrations to the database
List all migrations and their status
Print the SQL for the named migration
Models
String field for short to mid-length text
Large text field
Integer field
True/False boolean field
Timestamp set when object is created
Many-to-one relationship
Many-to-many relationship
One-to-one relationship
Set object string representation in admin and shell
ORM Querying
Get all records
Get a single record (throws DoesNotExist if missing)
Filter records
Exclude records matching condition
Order by field (descending)
Create and immediately save a new record
Case-insensitive substring match
Greater than or equal to comparison
Eager load related objects (Performance)
Count number of records
Views & URLs
Simple Function-Based View (FBV)
Render a template
Redirect to another URL
Define a URL pattern
URL with an integer parameter
Templates
Output a variable in a template
If-else conditions
For loop iteration
Inherit a parent template
Define or override a template block
Include another template
Reverse resolve a URL by name
Generate a URL for a static file
CSRF protection for POST forms
Apply a filter to format a date
Advanced
Explore advanced configurations for Django
Performance tuning best practices for Django
Run security checks and validation for Django
🔥 Similar Tools
Explore LibraryFrequently Asked Questions
Got questions? We've got answers.