On Sat, 2008-04-12 at 22:13 -0300, Juanjo Conti wrote:
> Suppose this template code:
> 
> {% for a in list %}
>       a.foo   a.bar
> {% endfor %}
> 
> The point is that only some elements of the "list" sequence have the 
> "foo" attribute, so a exception is thrown, but the template engine 
> silence it.
> 
> Is may template code correct or some check should be done to avoid the 
> exception throw?

It depends on what you want to happen.

The template rendering is designed to behave as you are describing. It
actually makes it easier to write reusable templates because you can
access the "foo" attribute on something without worrying about whether
it is present or not -- meaning the templates work for a broader range
of objects. Any missing attributes are replaced with the empty string.

So why is this a bad thing in your case and what do you want to have
happen instead?

Malcolm

-- 
Atheism is a non-prophet organization. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to