diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-12-09 01:55:53 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-12-09 01:55:53 +0000 |
| commit | b625153b49bf09c36caf9e4a75b0125092d8da56 (patch) | |
| tree | a4bd278d091098a0f1af46a9f9e33e945763b756 | |
| parent | 8da17bacf337117b1912fe12ce591a25a7e56021 (diff) | |
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
| -rw-r--r-- | django/views/generic/date_based.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py index b467efdd75..ca4b4b86e3 100644 --- a/django/views/generic/date_based.py +++ b/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(): |
