带有
的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?'
任何帮助?
答案 0 :(得分:0)
如果你将was_published_recently添加到list_display:
class QuestionAdmin(admin.ModelAdmin):
# ...
list_display = ('question_text', 'pub_date', 'was_published_recently')