爲什麼我無法使用page.item_set
獲取頁面模型的相關項目? 我得到以下錯誤:無法獲取相關設置
'Page' object has no attribute 'item_set'
我的代碼:
class Page(models.Model):
survey = models.ForeignKey(Survey)
title = models.CharField(max_length=256)
parent = models.ForeignKey("Page", blank=True, null=True, related_name="parent_page")
def __unicode__(self):
return self.title
class Item(models.Model):
page = models.ForeignKey(Page, related_name="item")
key = models.CharField(max_length=256)
value = models.CharField(max_length=256)
image = models.ImageField(upload_to="builder/item", null=True, blank=True)
options = models.ManyToManyField(Option, blank=True)
goto = models.ForeignKey(Page, null=True, blank=True, related_name="goto_page")
def __unicode__(self):
return self.value