You should be able to use the properties of a for loop to get the
first and last items.
{% for course_part in course.coursepart_set.all %}
{% if forloop.first %}
{{ course_part.begin_date }}
{% endif %}
{% if forloop.last %}
{{ course_part.end_date }}
{% endif %}
{% endfor %}
HTH,
Brandon
On Sep 3, 11:01 pm, watusee <[email protected]> wrote:
> I'm attempting to get the first and last items in a set inside a
> django template. The first is no problem:
>
> {{ course.coursepart_set.all.0.begin_date }}
>
> but I can't figure out how to get the last item without knowing the
> length of the set. Is there a way to do this?
>
> Something like (theoretically):
>
> {{ course.coursepart_set.all.LAST.end_date }}
>
> kind regards,
>
> -raymond
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---