#3481: request: else part for a for loop or make if to create variable
------------------------------------+---------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: new | Component: Template system
Version: 0.95 | Keywords: for if else loop
Stage: Unreviewed | Has_patch: 0
------------------------------------+---------------------------------------
When using the object_detail generic view:
If you have for examle a blog entry Entry(), and comments Comment() on it;
I would use this to loop for comments:
{{{
{% for comment in object.comment_set.all %}
{{ comment.body_text }}
<hr>
{% endfor%}
}}}
Now the problem is; it is impossible to display something in case there
are no comments without hitting the database again.
It could be fixed with an '{% elsefor %}' or by making it possible to
assign object.comment_set.all to some var once.
Another solution would be to make '{% if object.comment_set_all %}' create
a variable 'if.result' or something.
--
Ticket URL: <http://code.djangoproject.com/ticket/3481>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---