The makemigrations Command
Running makemigrations
From your project's root folder (where manage.py lives), running makemigrations compares your current models.py against the last recorded migration and writes a new file for anything that changed.
Example: Running makemigrations
Django scans all installed apps and prints something like 'Migrations for blog: 0002_article_published.py' for each change it found.
python manage.py makemigrations
⚠️ Run this command in your terminal.
Targeting a Single App
Passing an app's name after makemigrations restricts the scan to just that app, which is useful in a large project with many apps.
Example: Targeting a Single App
Only the blog app's models are checked; other installed apps are left untouched even if they also changed.
python manage.py makemigrations blog
⚠️ Run this command in your terminal.
Reading the Output
makemigrations prints the app name and the new migration filename it created, plus a short list of what each operation does, so you can sanity-check the change before applying it.
Warning: Read the printed operation list carefully — it tells you exactly what will happen to your tables.
Example: Reading the Output
The comment lines show Django's own explanation of the change it detected, matching the new BooleanField added to the model.
python manage.py makemigrations
# Migrations for 'blog':
# blog/migrations/0002_article_published.py
# - Add field published to article
⚠️ Run this command in your terminal.
Naming a Migration
The --name flag lets you give a migration a meaningful name instead of Django's auto-generated one, which makes the migrations folder easier to read later.
Example: Naming a Migration
The resulting file is named 0002_add_published_flag.py instead of an auto-generated description.
python manage.py makemigrations blog --name add_published_flag
⚠️ Run this command in your terminal.
- Running makemigrations but forgetting to run migrate afterward, so the database never actually receives the change.
- Editing a model field's name directly and assuming Django will silently detect it as a rename instead of asking whether it's a rename or a new field.
- Running makemigrations for one app and expecting it to also pick up changes in unrelated apps that weren't touched.
- makemigrations scans every app in INSTALLED_APPS for model changes.
- It writes a new numbered file into that app's migrations/ folder.
- It does not touch the database itself — that's migrate's job.
- You can target a single app by name to only check that app.
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: