Menu

Django 'Relation Does Not Exist': What It Means and How to Fix It
πŸ“°

Django 'Relation Does Not Exist': What It Means and How to Fix It

DEV Community: djangoΒ·Ubaid UllahΒ·5 days ago
#pXDfXjJW
#devtodjango#devto#dev#migration#table
Reading 0:00
15s threshold

Originally published on Djangix .

Your Django app says relation 'blog_post' does not exist, but the model is right there in models.py. This post shows how to find out whether the migration was never applied, never created, faked, or run against the wrong database β€” and the exact command that fixes each case.

Short answer

Short answer: the error means Django asked PostgreSQL for a table that is not in the database it is connected to. The table name in the message is the one Django expects β€” usually the app label plus the lowercase model name, such as blog_post. In almost every case the cause is one of four things: the migration was never applied, the migration file was never created or committed, the migration was recorded as applied without ever running, or the app is connected to a different database or schema than the one you migrated.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.