Opened 3 years ago

Last modified 20 months ago

#17508 assigned New feature

DateDetailView should accept less specific dates, ie Year/Month or just Year

Reported by: AndrewIngram Owned by: moonlimb
Component: Generic views Version: master
Severity: Normal Keywords:
Cc: andy@…, hirokiky@…, moonlimb@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

DateDetailView currently expects segments for year, month and day in the URL. This introduces the requirement to have an archive page for each level of the date; ie a year archive, a month archive, and a day archive:

/2012/
/2012/jan/
/2012/jan/06/
/2012/jan/06/blog-entry-name/

I don't think I'm inaccurate in saying that most bloggers (as opposed to news sites) don't usually create more than one post a day, and many (myself included) have a frequency of much less than once per month. This means we're introducing views such as day archive that have exactly the same information as the higher levels. As a URL purist, I don't like unnecessary segments in my schema and unnecessary pages in my information architecture.

In my case my URL structure is as follows, I don't use DayArchive at all:

/2012/
/2012/jan/
/2012/jan/blog-entry-name/

I've achieved this by creating my own version of DateDetailView that removes the use of DayMixin, but I think this can also be achieved by modifying DateDetailView itself to allow looser date matching using configuration of the view itself.

Is this a common enough use case to be worth making the change in Django itself? I think it can be done without affecting backwards compatibility.

Attachments (1)

t17508_1.diff (2.5 KB) - added by hirokiky 2 years ago.
Patch to accept less specific dates for DateDetailView.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by aaugustin

  • Owner changed from nobody to aaugustin

comment:3 Changed 3 years ago by aaugustin

  • Owner changed from aaugustin to nobody

Changed 2 years ago by hirokiky

Patch to accept less specific dates for DateDetailView.

comment:4 Changed 2 years ago by hirokiky

  • Cc hirokiky@… added
  • Has patch set
  • Needs documentation set
  • Needs tests set
  • Version changed from 1.3 to master

I added a patch.

Now, DateDetail takes a attribute to set the unity of dates named date_separate_unit.
The attribute allows a vaule, which daily, monthly or yearly:

  • daily: /2012/jan/06/blog-entry-name/
  • monthly: /2012/jan/blog-entry-name/
  • yearly: /2012/blog-entry-name/

How do you feel about this behavior and implementation?
I think it is better to hear someone's opinion.

comment:5 Changed 20 months ago by moonlimb

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned

comment:6 Changed 20 months ago by moonlimb

  • Cc moonlimb@… added
  • Owner changed from anonymous to moonlimb
Note: See TracTickets for help on using tickets.
Back to Top