Django Migration Error: Column does not exist Django Migration Error: Column does not exist postgresql postgresql

Django Migration Error: Column does not exist


After you run makemigrations, be sure to go through the stack trace step by step.

In my case, I noticed it traced through a call to a Form contained within a forms.py in a completely different app, which happened to have a call to the model I was trying to create a new migration for.

Moving the Form class out of forms.py into the views.py fixed the issue.


This bug was resolved for me by commenting out the django debug toolbar from INSTALLED_APPS in settings.py. I am not sure why debug toolbar is the culprit, but after I commented it out, I was able to run makemigrations and migrate with no issue.

Hoping this helps someone, as I spent twelve hours trying to figure it out.


In my case, that was because I had a unique_together constraint that was set.

When I wanted to remove a field, the auto-generated migration tried to remove the field before removing the unique_together constraint.

What I had to do was manually move up the migrations.AlterUniqueTogether constraint in the migration file, so that django removes first the constraint before trying to remove the field.

I hope this can help someone.