ProgrammingError: relation does not exist after migration
ProgrammingError: relation does not exist
$ python manage.py shell -c "from app.models import Item; print(Item.objects.count())"
# Traceback with ProgrammingError: relation "app_item" does not exist
Why this happens
Migrations not applied to the current database or you’re pointing to a different DB.
Fix
Run migrations for the active settings and ensure DATABASES points to the correct instance.
Wrong code
# Using test DB settings by accident
DATABASES = test_databases
Fixed code
# Ensure production/dev settings match your environment
# python manage.py migrate