[Django] #35994: WeekArchiveView sometimes gets the next week year wrong in the last week of the year

6 views
Skip to first unread message

Django

unread,
Dec 10, 2024, 8:39:51 AM12/10/24
to django-...@googlegroups.com
#35994: WeekArchiveView sometimes gets the next week year wrong in the last week of
the year
-------------------------------------+-------------------------------------
Reporter: Nigel Metheringham | Type: Bug
Status: new | Component: Generic
| views
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
In some cases - for example ISO or Monday start weeks in 2024, the last
week of the year has the next week set as week 1 of 2024, and not week 1
of 2025.

Sample code:

{{{
class TicketScheduleWeekView(WeekArchiveView):
"""View of tickets scheduled for a week."""

# queryset = ## Queryset deleted as its quite large
date_field = "date"
week_format = "%W"
year_format = "%Y"
allow_future = True
allow_empty = True
}}}

Given the following URL definition:
{{{
path("ticketschedule/<int:year>/<int:week>/",
views.TicketScheduleWeekView.as_view(), name="ticket-schedule-week"),
}}}

We get for end of year links:-
- `/ticketschedule/2023/51/` - next week link is
`/ticketschedule/2023/52/`
- `/ticketschedule/2024/52/` - next week link is `/ticketschedule/2024/1/`
- `/ticketschedule/2024/51/` - next week link is
`/ticketschedule/2024/52/`
- `/ticketschedule/2024/52/` - next week link is
`/ticketschedule/2024/1/` **wrong**
--
Ticket URL: <https://code.djangoproject.com/ticket/35994>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 10, 2024, 9:37:56 AM12/10/24
to django-...@googlegroups.com
#35994: WeekArchiveView sometimes gets the next week year wrong in the last week of
the year
------------------------------------+--------------------------------------
Reporter: Nigel Metheringham | Owner: (none)
Type: Bug | Status: closed
Component: Generic views | Version: 5.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Nigel Metheringham):

* resolution: => invalid
* status: new => closed

Comment:

Apologies. When looking deeper into this I discovered that I had the
following in the template:-
{{{
<li class="page-item">
<a class="page-link"
href="{% url 'ticket-schedule-week' next_week.year
next_week.isocalendar.week %}">Next &raquo;</a>
</li>
}}}

when it should have been
{{{
<li class="page-item">
<a class="page-link"
href="{% url 'ticket-schedule-week'
next_week.isocalendar.year next_week.isocalendar.week %}">Next &raquo;</a>
</li>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35994#comment:1>
Reply all
Reply to author
Forward
0 new messages