psycopg2.errors.UndefinedTable: relation "libman_classbooks" does not exist


I had mistakenly deleted my migration folders for all my apps in my project. I therefore had to redo makemigrations and migrate for each of those apps. When thence I try to access the specific areas with relational paths I get an error.

relation "libman_classbooks" does not exist

When I try to make some changes on the models, save and try to run makemigrations and migrate. this does not go on well but returns.

django.db.utils.ProgrammingError: relation "libman_classbooks" does not exist.

I have been forced to guess that I need to manually create the tables in the database. Using CREATETABLE. I don’t know if this is the best option though.
So I think my option may be possible in development thro’ the pgAdmin, but what about in production? If CREATETABLE is the best option to take, how will I do it for the production database??. I already have data in my database which do not need interference.


If you got this type issue Created a Custom_user model but not able to make connection or getting issue when we are running command docker-compose

Answer –

  1. To resolve this issue, you have to comment 'django.contrib.admin' this line in in installed app section, and then run command docker exec -it <db-container name or ID> psql -U postgres and check your database is exist or not if exist then Drop the DB and create new DB with same name.
  2. After creating DB again run docker-compose up Now it will work and again uncomment the line which was commented in
  3. Another approach In case if it is not working add this line in in installed app section 'app.apps.AppConfig'then run docker- compose up it will work for you.

Answered By – nikhil upadhyay

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published