#10890 closed New feature (fixed)
generic views archive_week and archive_day should have next/previous as Template Context
Reported by: | ee_lars | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Normal | Keywords: | generic views date_based archive_day archive_week |
Cc: | ben.welsh@…, michel@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Theses two generic views don't manage next/previous day/week.
It could be usefull and more coherent with archive_month and archive_year views which deal with these feature.
Attachments (2)
Change History (16)
comment:1 by , 16 years ago
milestone: | 1.1 |
---|
by , 15 years ago
Attachment: | week_pagination.diff added |
---|
comment:2 by , 15 years ago
Has patch: | set |
---|---|
Needs tests: | set |
I've attached a patch that tries to tackle the issue.
One complication: There isn't a week attribute on datetime objects, or at least I'm not aware of it. Typically, I use dt.isocalendar()[1] to get week numbers. But that's a pretty big hassle to do in your templates, so I'm not sure that just passing out a datetime object, as is done with the other date_based generic views, will work here.
If you check out my patch, what I tried was passing out dictionaries instead. Each with a 'year' and 'week' attribute that contains integers, and a 'date' key that hooks you up with the datetime object, if you happen to want that as well.
Dumb idea?
comment:3 by , 15 years ago
Cc: | added |
---|
comment:4 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 14 years ago
Cc: | added |
---|
comment:6 by , 14 years ago
Palewire: I think you can use "day.strftime('%U')" instead of "day.isocalendar()[1]". With the second choice, you can't do an easy navigation because the week numbers of day.isocalendar() are different from the result of the '%U'.
Once django itself uses the '%U' to know what week we are, using it in the dates will be better. I will send a patch.
I will make the tests and documentation for it too, maybe it can appear in the django1.3?
comment:7 by , 14 years ago
I'm totally open to alternatives and if your fix dovetails with a broader change to the Django core, all the better.
comment:8 by , 14 years ago
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
Patch needs to be updated for class-based views.
comment:9 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:12 by , 13 years ago
Owner: | changed from | to
---|
comment:13 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
An addition to the archive_week generic view that adds next_week and previous_week objects to the context for easier pagination in your templates