On 7/19/06, Grigory Fateyev <[EMAIL PROTECTED]> wrote:
> 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')

Unless I'm missing something, what you want is:

date_list = []
year_list = Article.objects.order_by('-pub_date').dates('pub_date', 'year')
for y in year_list:
    date_list.append({'year': y.year, 'months':
Article.objects.filter('pub_date__year__exact=y.year').order_by('-pub_date').dates('pub_date',
'month')})

And then iterate in the template like this:

{% for dl in date_list %}
<h2>{{ dl.year }}</h2>
<ul>
{% for month in dl.months %}
<li>{{ month|date:"%B" }}</li>
{% endfor %}
</ul>
{% endfor %}


Admittedly, I'm not entirely awake and alert right now (got no sleep
last night), but that feels like the right solution.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to