Opened 15 years ago

Closed 14 years ago

#1381 closed defect (worksforme)

'django.views.generic.date_based.archive_index' doesn't return latest objects first

Reported by: jakamkon@… Owned by: Jacob
Component: Generic views Version: master
Severity: trivial Keywords: django.views.generic.date_based.archive_index archive_index
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In django/views/generic/ we have:

def archive_index:
  lookup_kwargs = {'%s__lte' % date_field:} # *
  date_list = getattr(mod, "get_%s_list" % date_field)('year', **lookup_kwargs)[::-1]

Consider situation:

[datetime.datetime(2005, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)]

some_model.get_date_list('year', # situation as in *
[datetime.datetime(2005, 1, 1, 0, 0)] # we get the oldest year

In other words we get the oldest objects in place of the latest in our view.

When * is changed to:

 lookup_kwargs = {'%s__gte' % date_field:}

Now, we get the latest date:

[datetime.datetime(2006, 1, 1, 0, 0)]


Change History (2)

comment:1 Changed 14 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 14 years ago by Malcolm Tredinnick

Resolution: worksforme
Status: newclosed

This has been fixed in the interim at some point.

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