On 5/6/2009 5:32 PM, snorkel wrote:
> I am passing a model to a template that also has foreign keys to other
> models, so in my template I can do things like
> {% for a in a_list %}
>    {% for b in a.b_model.all %}
>     <p> this is b.name b.value  b.date </p>
>    {% endfor %}
> {% endfor %}
> 
> Is there some way to filter the b_model in the template or do I have
> to do this in views?
> For example only return b_model with date before Jan 2009 or with
> names beginning with c?

Depends on what you want to do. With the set of conditional template 
tags and filters, you can definitely perform some comparisons in the 
template itself for each b record based on some b.value.

For flexibility and power, you probably want to do it in the view, 
though. You don't have access to any QuerySet API that requires params 
inside the template.

-- 
George

--~--~---------~--~----~------------~-------~--~----~
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