1
0
mirror of https://github.com/django/django.git synced 2025-07-19 09:09:13 +00:00

[1.9.x] Fixed #26339 -- Updated Question.was_published_recently() in tutorial 7 to reflect changes in tutorial 5.

Backport of 602a38d87e4b0d9c5e43678c33208627ca84ce2a from master
This commit is contained in:
Tim Graham 2016-03-09 11:21:33 -05:00
parent e8d94cda9b
commit 43bb6727d0

View File

@ -232,7 +232,8 @@ attributes, as follows:
class Question(models.Model):
# ...
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date <= now
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'