Hello Adrian Holovaty! On Wed, 19 Jul 2006 10:10:20 -0500 you wrote: > > On 7/19/06, Grigory Fateyev <[EMAIL PROTECTED]> wrote: > > I want to get list of all months where objects present. First of > > all, using date_based generic views I could not extra_context > > additional like 'date_list', but decide to use my own view def. > > Hi Grigory, > > You can use the dates() QuerySet method to do this. Example: > > Article.objects.dates('pub_date', 'month') > > Here are the docs: > > http://www.djangoproject.com/documentation/db_api/#dates-field-kind-order-asc
Thanks, Adrian, for replying. Now I do like so: [...] y=Article.objects.all().order_by('-pub_date').dates('pub_date','year') m=Article.objects.all().order_by('-pub_date').dates('pub_date','month') return render_to_response('articles/articles_list.html', { 'object_list': l, 'year_list': y, 'month_list': m, [...] and template: <ul> {% for year in year_list %} <li><a href="{{ year|date:"Y" }}">{{ year|date:"Y" }}</a> <ul> {% for month in month_list %} <li>{{month|date:"F"}} {% endfor %} </ul> {% endfor %} </ul> This gives me: 2002 list of all months 2003 list of all months 2004 list of all months 2005 list of all months but it should be: 2002 list of months in 2002 2003 list of months in 2003 2004 list of months in 2004 2005 list of months in 2005 How fix this behavior? Sorry, if my explanations looks very stupid :) -- ÷ÓÅÇÏ ÎÁÉÌÕÞÛÅÇÏ! greg [at] anastasia [dot] ru çÒÉÇÏÒÉÊ. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---