'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.



Solution 1:[1]

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 setting.py 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 settings.py
  3. Another approach In case if it is not working add this line in settings.py in installed app section 'app.apps.AppConfig'then run docker- compose up it will work for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nikhil upadhyay