Opened 17 years ago

Last modified 13 years ago

#6749 closed

Generic week view displays Sunday objects in both the current and next week — at Version 2

Reported by: Jim Garrison Owned by: nobody
Component: Generic views Version: dev
Severity: Normal Keywords: archive_week
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

Objects on a Sunday are mistakenly displayed in both the correct week and the previous week.

The relevant code from django/views/generic/date_based.py (function archive_week):

    # Calculate first and last day of week, for use in a date-range lookup.
    first_day = date
    last_day = date + datetime.timedelta(days=7)
    lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)}

first_day is set from date, which is the Sunday that begins the week. However, last_day is then set to be the day 7 days after that day, which is the next Sunday. The final line above sets the range to be from one Sunday to the next Sunday, but the range test is inclusive so both Sundays are included by mistake.

This bug can be fixed by changing the 7 to a 6. Trivial patch is attached.

Change History (3)

by Jim Garrison, 17 years ago

Attachment: week_view.diff added

comment:1 by Pete Crosier, 17 years ago

Keywords: archive_week added
Summary: Generic week view displays Sunday objects in both the current and previous weekGeneric week view displays Sunday objects in both the current and next week
Triage Stage: UnreviewedAccepted

Seems like a simple error, changed what I guess was a type in the title too (extra Sunday used is in the next week).

comment:2 by Ramiro Morales, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top