summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2013-09-28 00:40:43 +0200
committerBaptiste Mispelon <bmispelon@gmail.com>2013-09-28 00:46:37 +0200
commitc2a35d40db3eca728ac809a3ddb5e8fcec463bca (patch)
tree38d0dadb315fd37496cf8a989340cbb27c10074d /django
parent15bdc85117785d583b9ae71d256929a431478f4c (diff)
[1.6.x] Fixed #21186: Fixed regression when using date fields in the admin's list_filter.
Thanks to onlygoldi2201 for the report and to ramiro and apollo13 for the reviews. Backport of 8f51ba669aba94eea684ea3f3429fd8e39e70679 from master.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/admin/filters.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 4131494515..2515bab458 100644
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -301,6 +301,11 @@ class DateFieldListFilter(FieldListFilter):
else: # field is a models.DateField
today = now.date()
tomorrow = today + datetime.timedelta(days=1)
+ if today.month == 12:
+ next_month = today.replace(year=today.year + 1, month=1, day=1)
+ else:
+ next_month = today.replace(month=today.month + 1, day=1)
+ next_year = today.replace(year=today.year + 1, month=1, day=1)
self.lookup_kwarg_since = '%s__gte' % field_path
self.lookup_kwarg_until = '%s__lt' % field_path
@@ -316,11 +321,11 @@ class DateFieldListFilter(FieldListFilter):
}),
(_('This month'), {
self.lookup_kwarg_since: str(today.replace(day=1)),
- self.lookup_kwarg_until: str(tomorrow),
+ self.lookup_kwarg_until: str(next_month),
}),
(_('This year'), {
self.lookup_kwarg_since: str(today.replace(month=1, day=1)),
- self.lookup_kwarg_until: str(tomorrow),
+ self.lookup_kwarg_until: str(next_year),
}),
)
super(DateFieldListFilter, self).__init__(