register = Library()
def show_user_info():
return "is_good"
register.tag('show_user_info', show_user_info)
{% show_user_info %}
Request Method: GET
Request URL: http://localhost/rin/bugcatcher/
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag: 'show_user_info'
Exception Location: C:\server\python\lib\site-packages\django\template\__init__.py in invalid_block_tag, line 335
Python Executable: C:\server\apache\bin\httpd.exe
Python Version: 2.5.4
FerromanЭммм… там вообще-то написано, что теги во-первых во views.py не живут, а потом, что их надо подгружать, указывая имя модуля, а не самого тега :-)
Внимательнее читайте документацию, там ясно написано что надо сделать {% load темплейттаг %}
Caught an exception while rendering: show_user_info() takes no arguments (2 given)
'mysite.templatetags',
'userinfo' is not a valid tag library: Could not load template library from django.templatetags.userinfo, No module named userinfo
Caught an exception while rendering: show_user_info() takes no arguments (2 given)
from django.template import Library
register = Library()
@register.tag(name="show_user_info")
def show_user_info():
return "is_good"