problem with simple templatetags usage in django
I try to use templatetags in django but I have trouble.
I defined enumhelper.py
in the templatetags package.
Then I load it at the top of employer_list.html
like
开发者_如何学JAVA{% extends "base.html" %}
{% load enumhelper %}
{% block title %}{% endblock %}
Content of enumhelper.py
is really simple.
register = template.Library()
@register.tag()
def enum_worker_number_range():
return "sdsdsd"
Then I want to use enum_worker_number_range
in the employer_list.html
as
{% block enumhelper %}
{{ enum_worker_number_range }}
{% endblock %}
I expect to write sdsdsd
at the page but I couldn't see anything. I am sure that load opearition is sucessful beacuse when I change enumhelper
name it gives error.
Although load operation is successful, why I can't see the return value of enum_worker_number_range
?
Thanks
@register.simple_tag
def enum_worker_number_range():
return "sdsdsd"
精彩评论