Django Models (1054, “Unknown column in 'field list'”)

后端 未结 13 1736
庸人自扰
庸人自扰 2020-12-08 13:18

No idea why this error is popping up. Here are the models I created -

from django.db import models
from django.contrib.auth.models import User

class Shows(m         


        
13条回答
  •  孤城傲影
    2020-12-08 13:46

    This is quite an old question but you might find the below useful anyway: Check the database, you're most likely missing the show_id in the appname_usershow table.

    This could occur when you change or add a field but you forget running migration.

    OR

    When you're accessing a non managed table and you're trying to add a ForeignKey to your model. Following the example above:

    class UserShow(models.Model):
        # some attributes ...
        show = models.ForeignKey(Show, models.DO_NOTHING)
    
        class Meta:
            managed = False
            db_table = 'appname_departments'
    

提交回复
热议问题