Reputation: 1893
When using the Django Admin panel, I am able to add new instances to Users and Groups. The same thing goes for all my apps, except for one. This one app, resultregistration, always gives me a ProgrammingError whenever I try to add a new model. For example, this app has a Competition-model where data about a sport competition should be stored.
When I click "+ Add" I am taken to the correct site where I can add a new competition. However, when I press save I get:
ProgrammingError at /admin/resultregistration/competition/add/
column "competition_category" of relation "resultregistration_competition" does not exist LINE 1: INSERT INTO "resultregistration_competition" ("competition_c...
Of course, I assume something is wrong with the migrations. However, I have run python manage.py makemigrations appname, and python manage.py migrate appname, and that works fine. I get a message that there are "No changes detected", and "No migrations to apply".
I have tried solutions posted on SO, but none of them worked.
What is the general reason for this error? And does anyone know what could be wrong in this specific case? Could one get this error if something is wrongly defined in the model? Or does it have to be a migration problem?
Thank you so much! Any help would be truly appreciated. Also, I am using PostgreSQL, if that helps.
Upvotes: 1
Views: 934
Reputation: 610
If nothing works and there isnt much data present in your database, end resolution is to delete all migrations files (if any) for that app or for the project, in terminal type "sudo -su postgres" then type "psql".
Drop your database and create a new one. Run manage.py makemigrations to check if migration file has been created or not. Then migrate with manage.py migrate
Upvotes: 3