Questions tagged «django-custom-tags»

3
Django自定义模板标签中的访问请求
我在myapp_extras.py中的代码: from django import template register = template.Library() @register.inclusion_tag('new/userinfo.html') def address(): address = request.session['address'] return {'address':address} 在“ settings.py”中: TEMPLATE_CONTEXT_PROCESSORS =( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", 'django.core.context_processors.request' ) 但我得到一个错误: TemplateSyntaxError at /items/ Caught an exception while rendering: global name 'request' is not defined Original Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\debug.py", line …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.