Monday, July 26, 2010

how to create a custom django template filter(please help)

hi
im a newbie if u know please answer me
i just follow steps of django website
http://www.djangoproject.com/documentation/0.96/templates_python/

create a directory under inside has two file _init_.py and
customTags.py

content of customTags.py

from google.appengine.ext.webapp import template
register = webapp.template.create_template_register()
@register.filter(name='test')
def test(value):
if len(value)>0:
value = 1
return value
else:
value=0
return value

#test.is_safe = True
register.filter('test', test)

and i also do this {% load customTags %} in the index.html


but there is some wrong occur....

TemplateSyntaxError: 'customTags' is not a valid tag library: Could
not load template library from django.templatetags.customTags, No
module named customTags


if u know please tell me

tks
Joseph

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment