Django模型(1054,“字段列表中的未知列”)

36 浏览
0 Comments

Django模型(1054,“字段列表中的未知列”)

不知道为什么会出现这个错误。以下是我创建的模型 -

from django.db import models
from django.contrib.auth.models import User
class Shows(models.Model):
    showid= models.CharField(max_length=10, unique=True, db_index=True)
    name  = models.CharField(max_length=256, db_index=True)
    aka   = models.CharField(max_length=256, db_index=True)
    score = models.FloatField()
class UserShow(models.Model):
    user  = models.ForeignKey(User)
    show  = models.ForeignKey(Shows)

以下是我从中访问这些模型的视图 -

from django.http import HttpResponse
from django.template import Context
from django.template.loader import get_template
from django.http import HttpResponse, Http404
from django.contrib.auth.models import User
def user_page(request, username):
    try:
        user = User.objects.get(username=username)
    except:
        raise Http404('未找到请求的用户。')
    shows     = user.usershow_set.all()
    template  = get_template('user_page.html')
    variables = Context({
        'username': username,
        'shows'   : shows})
    output = template.render(variables)
    return HttpResponse(output)

在这一点上,我收到一个错误 -

OperationalError: (1054, "在'字段列表'中未知列'appname_usershow.show_id'")

如你所见,这个列甚至不在我的模型中,为什么会出现这个错误?

0