Opened 8 years ago

Closed 5 years ago

#6749 closed Bug (duplicate)

Generic week view displays Sunday objects in both the current and next week

Reported by: garrison Owned by: nobody
Component: Generic views Version: master
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)

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

The relevant code from django/views/generic/ (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.

Attachments (1)

week_view.diff (621 bytes) - added by garrison 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by garrison

comment:1 Changed 8 years ago by PJCrosier

  • Keywords archive_week added
  • Summary changed from Generic week view displays Sunday objects in both the current and previous week to Generic week view displays Sunday objects in both the current and next week
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 8 years ago by ramiro

  • Description modified (diff)

comment:3 Changed 7 years ago by SmileyChris

  • Needs tests set

comment:4 Changed 6 years ago by russellm

  • Patch needs improvement set

Needs to be updated for class-based views.

comment:5 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:6 Changed 5 years ago by koenb

  • Easy pickings unset
  • Resolution set to duplicate
  • Status changed from new to closed
  • UI/UX unset

It seems this was already fixed in r8476 (fix for #7602).

Closing as duplicate.

Note: See TracTickets for help on using tickets.
Back to Top