当我的目录模型中添加了一个字段时,我在Django中返回错误。该模型只需使用" Article"外键,但当"年度"添加了外键我在admin中收到以下错误:
no such column: subscriber_catalog.annual_items_id
导致此错误的原因是什么?
class Annual(models.Model):
year_id = models.IntegerField(max_length=4)
start_date = models.CharField(max_length=6)
end_date = models.CharField(max_length=6)
def __unicode__(self):
return unicode(self.year_id)
class Annual_Issue(models.Model):
annual_id = models.ForeignKey(Annual, related_name='annual_ids')
issue_id = models.ForeignKey(Issue, related_name='issues')
def __unicode__(self):
return self.annual_id
class Article(models.Model):
title = models.CharField(max_length=200)
abstract = models.TextField(max_length=1000, blank=True)
full_text = models.TextField(blank=True)
proquest_link = models.CharField(max_length=200, blank=True, null=True)
ebsco_link = models.CharField(max_length=200, blank=True, null=True)
def __unicode__(self):
return self.title
class Catalog(models.Model):
issue_items = models.ForeignKey(Issue, related_name='catalogissue')
annual_items = models.ForeignKey(Annual, related_name='catalogannual')
答案 0 :(得分:2)
它正在寻找annual_items_id,但在您的模型中,以simmilar方式命名的唯一字段称为annual_id ...检查您的字段命名以及是否正确应用迁移