0
0
DjangoHow-ToBeginner · 3 min read

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.py runs Django management commands.
  • showmigrations is 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.py is located.
  • Forgetting to activate the virtual environment if Django is installed there.
  • Confusing showmigrations with migrate which 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.