On Mon, 2009-02-16 at 21:49 -0800, xankya wrote: > hi, > i need to do the following kind of template logic. can i achieve > this using built in tags or i need to create custom tags? > > {% if user in voter_list %} > You have already voted. > {% else %} > <a href="/vote/">Vote</a> > {% endif %}
You can't do this with any of the builtins. At least not that I can figure out. I would probably create a filter that acts on the list and takes "user" as the argument and returns true or false, depending on whether the argument is in the list. Then you can use that filter inside the existing "if" template tag. Suppose the filter is called "contains", you could write: {% if voter_list|contains:user %} ... {% endif %} This might be a little easier than writing a full-on block-based template tag. It also reads fairly naturally, to my eye. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---