Opened 10 years ago

Closed 9 years ago

#3585 closed (wontfix)

django.views.generic.date_based.archive_{month,day}: date of first object outside interval available in template context

Reported by: Per Jonsson <poj@…> Owned by: nobody
Component: Generic views Version: master
Severity: Keywords:
Cc: poj+django@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Ticket #2368 suggests that in django.views.generic.date_based generic views, previous_month and previous_day should reflect if there is objects in those months.

When trying to port the patch attached to #2368 to the state after the changes introduced in fixing #2433 with changeset [3457], I realised it was not entirely sensible.

The patch attached to this Ticket implements new variables in template context for django.views.generic.date_based.archive_month and django.views.generic.date_based.archive_day, previous_object_date and next_object_date, which gives the possibility to access the date of the first accessible object outside the interval in either direction.

Attachments (2)

gv_datebased_object_date.diff (8.8 KB) - added by Per Jonsson <poj@…> 10 years ago.
gv_datebased_object_date.2.diff (8.7 KB) - added by Per Jonsson <poj@…> 10 years ago.

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by Per Jonsson <poj@…>

Changed 10 years ago by Per Jonsson <poj@…>

comment:1 Changed 10 years ago by Per Jonsson <poj@…>

Updated the patch as there were a bug in the original one.

comment:2 Changed 10 years ago by Jacob

Triage Stage: UnreviewedDesign decision needed

It's not clear to me why this is needed; can you explain what's wrong with previous_month/day?

comment:3 in reply to:  2 Changed 10 years ago by Per Jonsson <poj@…>

previous_month/day is currently just the date of the month/day before the one currently shown, and doesn't tell if there are any objects there.

On use-case is that you are using allow_empty=True, and want to reference the month/day on either side of the currently displayed (to create links to empty pages, perhaps so that the user can bookmark them), but also want to link to the month/day with the closest accessible object outside the interval that is currently being shown.

It is possible that the information in previous_month/day should be changed to reflect the information my patch puts in previous_object_date, but that changes current behaviour.

comment:4 Changed 10 years ago by Per Jonsson <poj@…>

The reference in the Description to #2368 should be #2386.

comment:5 Changed 9 years ago by Jacob

Resolution: wontfix
Status: newclosed

I'm wary of further complicating generic views (they're already pretty hairy). Since you can do this with a wrapper around the generic view that sets extra_context, I think that's a better approach.

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