On 10/23/06, João Cruz Morais <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> Some time ago I've submitted this filter -
> http://code.djangoproject.com/ticket/2741 - because i thought it was too
> simple and obvious to be left outside the builtin pack.
> Adrian rejected the purposal, and never said why, so I'm wondering, do
> you know any other way to achieve this filter objective without, of
> course, resorting to new filters/tags/etc?
I haven't spoken to Adrian about his reasons, but I suspect I know why
he rejected this proposal, and I would have rejected it for the same
reason.
Django is very explicit about templates not containing view logic. If
you are checking set/list membership in a template, it indicates that
there is some aspect of the view that you are not adequately capturing
in your context.
The right way to do this would be to put the 'IN' condition as a
context variable (e.g., is_open: node.id in open_nodes), and then use
a standard 'if' template tag (e.g., {%if is_open %}).
This maintains the separation of template from view; you can modify
the conditions under which the is_open block is displayed without
having to modify the template.
Yours,
Russ Magee %-)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---