# -*- coding: utf-8 -*-
from django import template
register = template.Library()
@register.inclusion_tag('menu/create_minimenu.html', takes_context = True)
def minimenu(context):
....
....
@register.inclusion_tag('menu/create_topmenu.html', takes_context = True)
def topmenu(context):
....
....
@register.filter(name = 'commatodot')
def commatodot(value, arg):
return str(value).replace(",", '.')
commatodot.isSafe = True
template.html如何在django框架中正确定制过滤器?
...
initGeolocation2({{ place.longitude|commatodot }}, {{ place.latitude|commatodot }}, "MAIN");
...
错误:
TemplateSyntaxError at /places/3/
Invalid filter: 'commatodot'
Request Method: GET
Request URL: http://localhost:8000/places/3/
Django Version: 1.2.4
Exception Type: TemplateSyntaxError
Exception Value:
Invalid filter: 'commatodot'
这从文件的工作标签很好,但过滤不。但我不知道为什么......
它做...而templatetags和“包括”。但没有解决我的问题,以及我如何编写自定义标签。 – kspacja 2011-02-08 21:58:10
你不``包括``标签库,你`加载`它:`{%load apptags%}` – 2011-02-08 23:27:05