Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit b625153b49bf09c36caf9e4a75b0125092d8da56 1 parent 8da17ba
@adrianholovaty adrianholovaty authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 django/views/generic/date_based.py
View
12 django/views/generic/date_based.py
@@ -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():
Please sign in to comment.
Something went wrong with that request. Please try again.