django-custom-tags

Access request in django custom template tags

Access request in django custom template tags Question: My code in 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} in ‘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’ ) but I got an error: TemplateSyntaxError at /items/ Caught an exception while rendering: global name ‘request’ is not …

Total answers: 3