django教程missbehaviour

时间:2014-07-30 22:07:34

标签: python django

带有

的3行
was_published_recently

不工作,当我显示adminPoll时没有任何反应

django 1.6.5,python 2.7.6 ubuntu 14.04

class Poll(models.Model):
    # ...
    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

任何帮助?

1 个答案:

答案 0 :(得分:0)

如果你将was_published_recently添加到list_display:

class QuestionAdmin(admin.ModelAdmin):
# ...
    list_display = ('question_text', 'pub_date', 'was_published_recently')