That's exactly what I needed. Thanks a lot.

--
Gijs


On Aug 27, 4:31 pm, David Zhou <da...@nodnod.net> wrote:
> On Thu, Aug 27, 2009 at 10:10 AM, gnijholt<gijs.nijh...@gmail.com> wrote:
> > Or is there a better way to generate a full archive page (per year,
> > per month)?
>
> You'll need to test this, but you should be able to do that with {%
> ifchanged %}:
>
> #view:
> posts = Posts.objects.order_by('-pub_date')
>
> #template
>
> {% for post in posts %}
>     {% ifchanged post.pub_date.year %}
>         <h2>{{post.pub_date.year}}</h2>
>     {% endifchanged %}
>     {% ifchanged post.pub_date.month %}
>         <h2>{{post.pub_date.month}}</h2>
>     {% endifchanged %}
>     <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
> {% endfor %}
>
> -- dz
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to