django.db.utils.OperationalError: no such table: orders_order
Python · updated 2026-11-03
Raised on the first query against the missing table, often right after a deploy or on a fresh database. The table name is <app_label>_<model>, which tells you which app is missing its migration.
Traceback (most recent call last):
File "/app/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
return self.cursor.execute(sql, params)
File "/app/.venv/lib/python3.12/site-packages/django/db/backends/sqlite3/base.py", line 354, in execute
return super().execute(query, params)
sqlite3.OperationalError: no such table: orders_order
The above exception was the direct cause of the following exception:
...
django.db.utils.OperationalError: no such table: orders_orderQuick fix
Run python manage.py showmigrations on the server to see what is applied there. If the app has no migration for the model, run makemigrations locally and commit it; then run python manage.py migrate in the environment that raised the error, as part of every deploy.
- Read the table name: the part before the underscore is the app label.
- Run python manage.py showmigrations <app> where the error happened.
- If no migration exists for the model, run makemigrations locally and commit the file.
- Run python manage.py migrate in that environment, and add it to the deploy or release step.
- Check DATABASES points at the database you migrated (a different SQLite path or DATABASE_URL is a common cause).
# What does this environment have applied?
python manage.py showmigrations orders
# Create missing migrations (locally, then commit them)
python manage.py makemigrations orders
# Apply them where the app runs, on every deploy
python manage.py migrate --noinputWhy it happens
Migrations never applied in this environment
A deploy shipped new models but the release step that runs migrate was skipped, failed, or runs against a different database than the web process.
The migration file was never created or committed
makemigrations ran on one laptop and the file stayed there, often hidden by a .gitignore entry for migrations folders. Production has the model but no migration for it.
The app is missing from INSTALLED_APPS
Django only creates tables for apps listed in INSTALLED_APPS, so a new app without its entry has models but no tables.
Pointing at a different database file
With SQLite, a relative NAME resolves against the working directory, so a process started from another folder opens a new, empty database file.
Tests using a database without migrations
A test database built with migrations disabled, or a TestCase that queries a model from an app the test settings leave out, raises the same error in CI.
Other fixes
- Use an absolute SQLite path built from BASE_DIR (BASE_DIR / 'db.sqlite3').
- Run python manage.py makemigrations --check --dry-run in CI to fail builds that have model changes without migrations.
- Never delete migration files that production has already applied.
Same error, other wording
- django.db.utils.ProgrammingError: relation "orders_order" does not exist
- django.db.utils.OperationalError: no such column: orders_order.status
- django.db.utils.ProgrammingError: (1146, "Table 'app.orders_order' doesn't exist")
Let your coding agent catch the next one
Runheed records this error in production with the stack trace, the breadcrumbs before it and the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:
> Find the 'no such table' errors in production, tell me which app and table each is about and whether its migration exists in the repo, and add a migrate step to the deploy if one is missing.
Related errors
- psycopg2.OperationalError: server closed the connection unexpectedly
- ModuleNotFoundError: No module named 'x'
- KeyError: 'email'
References: Django docs: migrations, Django docs: django-admin migrate and showmigrations