How to Show Migration Status in Django
Use the
python manage.py showmigrations command to display the migration status in Django. This command lists all migrations and marks which ones are applied with an [X] and which are pending with [ ].Syntax
The basic syntax to show migration status in Django is:
python manage.py showmigrations [app_label]Here:
python manage.pyruns Django management commands.showmigrationsis the command to list migrations.[app_label]is optional and filters migrations for a specific app.
bash
python manage.py showmigrations [app_label]
Example
This example shows how to list all migrations and their status for the entire project and for a specific app named blog.
bash
python manage.py showmigrations python manage.py showmigrations blog
Output
[ ] admin
[X] auth
[ ] blog
[X] 0001_initial
[ ] 0002_auto
[X] contenttypes
[ ] sessions
blog
[X] 0001_initial
[ ] 0002_auto
Common Pitfalls
Common mistakes when checking migration status include:
- Not running the command in the project root where
manage.pyis located. - Forgetting to activate the virtual environment if Django is installed there.
- Confusing
showmigrationswithmigratewhich applies migrations instead of showing status. - Expecting detailed migration errors from this command; it only shows status.
bash
Wrong usage (no manage.py): python showmigrations Correct usage: python manage.py showmigrations
Quick Reference
- Show all migrations:
python manage.py showmigrations - Show migrations for one app:
python manage.py showmigrations app_label - Applied migrations: Marked with
[X] - Pending migrations: Marked with
[ ]
Key Takeaways
Run
python manage.py showmigrations to see migration status in Django.Applied migrations show with
[X], pending ones with [ ].You can check migrations for a specific app by adding its name after the command.
Always run the command from the project root where
manage.py is located.This command only shows status; use
python manage.py migrate to apply migrations.