On 6/28/06, dcurtis gmail.com <dcurtis gmail.com> wrote:
> i am currently looking at building a kinda daily posts
blog thing and
> basically i need this functionality. if the date
changes, i need a
> "date" header. if the date hasn't changed
but i'm on a new blog post i
> just need a simple separator. Now, at first i would
imagine this be
> the code:
>
> {% ifchanged %}
> <tr><th class="info"
colspan="2"><span
class="date">{{
> post.created|date:"Y.m.d"
}}</span></th></tr>
> {%else %}
> <hr />
> {% endifchanged %}
>
> but else is not a valid block tag. any insight from
devs or other
> users.
> i am using the
django.views.generic.date_based.archive_index generic
> view
Ah, we should add an {% else %} clause to the {% ifchanged
%} tag --
that'd be a nice addition.
For this solution, you could use {% regroup %}. The {%
regroup %} tag
is pretty complex and kind of hard to understand, but it's
powerful
for times like these.
{% regroup post_list by created as date_list %}
(Now post_list is a list of objects grouped by distinct
"created" values.
Each one has a "grouper" and a
"list" attribute.)
{% for date in date_list %}
<tr><th class="info"
colspan="2"><span
class="date">
{{ date.grouper|date:"Y.m.d" }}
</span></th></tr>
{% for entry in date.list %}
{{ entry.headline }} ...whatever
{% endfor %}
<hr />
{% endfor %}
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
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-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|