#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 Changed 15 years ago by
milestone: | 1.1 |
---|
Changed 14 years ago by
Attachment: | week_pagination.diff added |
---|
comment:2 Changed 14 years ago by
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 Changed 14 years ago by
Cc: | ben.welsh@… added |
---|
comment:4 Changed 14 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 Changed 14 years ago by
Cc: | michel@… added |
---|
comment:6 Changed 13 years ago by
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 Changed 13 years ago by
I'm totally open to alternatives and if your fix dovetails with a broader change to the Django core, all the better.
comment:8 Changed 13 years ago by
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
Patch needs to be updated for class-based views.
comment:9 Changed 13 years ago by
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:12 Changed 12 years ago by
Owner: | changed from nobody to Aymeric Augustin |
---|
comment:13 Changed 12 years ago by
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