0

I have a postgres database, which naming midgard_dev. It has a many tables.

After changing in models at product app I got error 'Column product_... does not exist'. I removed few tables in database, which related with product, and got error "Relation products_product does not exist. LINE 1: SELECT COUNT() AS "__count" FROM "products_product".

This error I get, when open page with product (from admin-panel or user-page)

I watched migrations (with ./manage.py showmigrations) and saw, that all migrations successful.

makemigrations app and migrate --fake don't help respectively. Delete the entire database don't want.

The tables that remained associated with the product The tables that remained associated with the product

Thnx for help.

  • It is impossible to answer this query without knowing what *exactly* you did and how your queries look. If you drop tables, I'd say that it is unsurprising if you get errors about missing tables... – Laurenz Albe Apr 03 '19 at 19:20
  • @LaurenzAlbe I don't know the `postgres` well. I do not know how and what information to provide, so that you can help me ... I really do not want to delete the entire database. This error only appears when I try to open pages that are related to `products`... –  Apr 03 '19 at 19:27
  • @LaurenzAlbe I deleted the `products_order`, `products_cart`, and other. The last thing I deleted is the `products_product` table (and its associated tables). After that, an error of this type appeared. Before that there was something like '_Column product_id (etc) does not exist_' –  Apr 03 '19 at 19:31
  • It seems that the error messages name the problem correctly. Probably the column didn't exist, so either don't reference it in your queries or add it to the table. Don't drop tables you still need. Can you restore a backup? Maybe you should get a programmer to look at the problem. – Laurenz Albe Apr 03 '19 at 19:37
  • Welcome @pythoner. You should provide more detail when asking questions. Here is an example of how to ask this kind of question https://stackoverflow.com/q/36753568/828757 – Jack Apr 04 '19 at 03:19
  • @Jack If I write `SELECT * FROM public.products_product;` I get `relation "`public.products_product`" does not exist` (or `SELECT * FROM products_product`) –  Apr 04 '19 at 07:29
  • I will guess there was a delete cascade trigger on the related table. So when you delete the parent table, the children are also deleted. – Juan Carlos Oropeza Jan 29 '23 at 15:38

1 Answers1

0

I had same error, I solved it by typing python manage.py makemigrations model_name then python manage.py migrate model_name to command promt/power shell. Reason could be that typing same commands without model_name do not create tables and/or relations for specific model(not professional opinion).model_name is name of your model.