Unknown column '' in 'field list'. Django

It looks as if you created and ran a migration to rename the model field from votes to votes_count, but did not update the model at the same time.

When the Django tries to fetch the model from the db, it tries to select the votes column because you still have a votes field in your models, and you get the error because the column doesn't exist in the database.

Creating a manual migration isn't normally necessary. Usually, you would rename the model field, run makemigrations, then run migrate. The advantage of letting Django create the migration is that you can be confident that the database is in sync with your models after you have run migrate.

Cause: This error occurs when a new one-to-many foreign key is created, pointing to the model with the forkey field and then generating the table


Solution: This problem can be solved by directly deleting the database and rebuilding it.

1: drop database database table;

2, re-create after deletion, before the code created, run directly