Skip to content
Advertisement

django.db.utils.ProgrammingError: relation ” – ” does not exist

(New to Django) – I am looking to create two model with a foreign key. The first model is called Portfolio, and each Portfolio has many member through the second model Portfoliomember. It currently looks like this:

JavaScript

Later i aim at using formset in a form. but for now, when i try to create the migration, i get the following :

JavaScript

Is there an obvious reason why this would not work ?

Advertisement

Answer

Why do you define in your Meta class db_table? I don’t know what is your app name but normally you don’t need to do that except for specific reason. See this (https://docs.djangoproject.com/en/3.1/ref/models/options/) ” Django automatically derives the name of the database table from the name of your model class and the app that contains it”.

So when you define db_table = ‘another_name’, you override the database table name. I would suggest to remove this line i.e. db_table = “portfoliomember” and see if the error persist.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement