Can't you use the % operator within if statements in templates? I was almost sure I'd done this before :|

On 09/12/2010 11:27, bruno desthuilliers wrote:
On 9 déc, 12:18, Phani Chand<balaphanich...@gmail.com>  wrote:
Can i use filter(lambda x: x%2, mylist) directly in my html page????
s/html page/template/

And no, you cannot use Python code in a template.
You can either
1/ filter the list in the view
2/ use the builtin "divisibleby" filter (http://docs.djangoproject.com/
en/1.2/ref/templates/builtins/#divisibleby)
3/ write your own "odds" and "evens" filters (http://
docs.djangoproject.com/en/1.2/howto/custom-template-tags/)

HTH


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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