Fixed #992 -- Fixed bug in archive_month generic view leaving out the last day of the month. Thanks, ubernostrum

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1571 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-12-09 01:55:53 +00:00
parent 8da17bacf3
commit b625153b49
1 changed files with 4 additions and 8 deletions

View File

@ -108,14 +108,10 @@ def archive_month(request, year, month, app_label, module_name, date_field,
now = datetime.datetime.now()
# Calculate first and last day of month, for use in a date-range lookup.
first_day = date.replace(day=1)
last_day = date
for i in (31, 30, 29, 28):
try:
last_day = last_day.replace(day=i)
except ValueError:
continue
else:
break
if first_day.month == 12:
last_day = first_day.replace(year=first_day.year + 1, month=1)
else:
last_day = first_day.replace(month=first_day.month + 1)
lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)}
# Only bother to check current date if the month isn't in the past.
if last_day >= now.date():