django教程后出错

时间:2011-10-09 14:10:56

标签: python django

我正在尝试遵循django教程,但我收到此错误,我无法继续。 http://dpaste.com/630957/

有人能帮助我吗? (我是python和django的新手)非常感谢你。

2 个答案:

答案 0 :(得分:3)

从错误日志中:

File "/arpa/h/huksy007/Projects/mysite/polls/models.py" in __unicode__
    22.         return self.question

确保self实际上有一个名为question的属性。

答案 1 :(得分:0)

你忘了把这一行放在你的选择模型上:

    choice = models.CharField(max_length=200)

需要像那样:

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()

编辑:

抱歉,我正在考虑别的事情,并没有意识到这条线应该改成你的模型:

def __unicode__(self):
    return self.choice

你可能在你的Choice模型上有这个:

def __unicode__(self):
    return self.question

并从民意调查模型中提出质疑。