Python 3, Django 1.8.5, Postgres
I have a model Sites that has been working fine. I recently tried to add a field, airport_code, and migrate the data.>
I ran into this issue as well and the answer by @Nexus helped. I thought I'd provide details of my specific case here for better illustrate the cause of the issue. It seems like a potential bug to me.
I have a model Brand as follows:
class Brand(BaseModelClass):
name = CharField(max_length=256, unique=True)
website = ForeignKey(URL, on_delete=CASCADE, null=True, blank=True)
I was running a python manage.py makemigrations after adding a Boolean field as follows:
class Brand(BaseModelClass):
name = CharField(max_length=256, unique=True)
website = ForeignKey(URL, on_delete=CASCADE, null=True, blank=True)
trusted = Boolean(default=True)
When running the makemigrations command, I recieved an error similar to OP's:
django.db.utils.ProgrammingError: column appname_brand.trusted does not exist
Per @Nexus' suggestion, I went through the stacktrace, line-by-line, assuming that it wasn't some core issue with Django. As it turns out, in one of apps forms.py file I had the following:
choices={(str(brand.id), brand.name) for brand in Brand.objects.all()}
The solution was to simply comment-out that line, run manage.py makemigrations, then run manage.py migrate. Afterwards, I uncommented the line and everything and my forms' functionality worked just as before.