问题
I am running django 1.7 & python 2.7.
In my postgressql db, I had some surplus tables. I now believe that the surplus tables were made surplus when I changed the names of many of my tables some time ago, before I upgraded to django 1.7. The surplus table names did not have any data in them.
After I checked my migrations and after searching my project for the surplus table names and finding no reference, I deleted/droped the tables.
I am able to update existing records and add new records, but after droping the tables, I cannot delete existing records.
The existing and correct table name is core_namedetails
. This is the table that stores all the users name details.
The table that I dropped in the postgressql db was core_resume_name_details
.
Here is the error that I am getting, when I try to delete a record from the core_namedetails
:
ProgrammingError at /resume_details/name_details/delete/251/
relation "core_resume_name_details" does not exist
LINE 1: DELETE FROM "core_resume_name_details" WHERE "core_resume_na...
^
Request Method: GET
Request URL: http://127.0.0.1:8000/resume_details/name_details/delete/251/
Django Version: 1.7.2
Exception Type: ProgrammingError
Exception Value:
relation "core_resume_name_details" does not exist
LINE 1: DELETE FROM "core_resume_name_details" WHERE "core_resume_na...
I have run makemigrations
and migrate
. No issues are returned.
I have searched google & SO, but nothing I found shed any light on my error.
Does anyone have any solutions to this issue?
回答1:
The problem is that your model is looking for core_resume_name_details
table. Possibly you are lost migration about renaming this table to core_name_details
.
Solution - add db_table = 'core_namedetails'
to your Model's Meta, or rename table core_namedetails
to core_resume_name_details
by your hands.
回答2:
The issue was a corrupt migration file. I eventually traced the corrupted file and fixed the offending line of code.
Hope that this helps someone.
来源:https://stackoverflow.com/questions/33007593/django-python-relation-does-not-exist