problem with simple templatetags usage in django
-
04-01-2021 - |
Frage
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
{% 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
Lösung
@register.simple_tag
def enum_worker_number_range():
return "sdsdsd"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow