[Django]-Access to RequestContext in Django template?

3👍

You have a typo, a missing ‘S’ at the end of TEMPLATE_CONTEXT_PROCESSORS, perhaps just in your question? Setting should be:

TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
 "django.core.context_processors.debug",
 "django.core.context_processors.i18n",
 "django.core.context_processors.media",
 "django.core.context_processors.static",
 "django.core.context_processors.tz",
 "django.contrib.messages.context_processors.messages",
 "django.core.context_processors.request",)

, not TEMPLATE_CONTEXT_PROCESSOR = .... I prefer to override the setting entirely so it’s clear what’s active (you might want to disable debug in production, for instance).

👤Steven

1👍

Do you use the Django’s Session framework? Then yes, request.session will do nothing, since the a session is a dict-like object and the template engine does not know how to render it.

Leave a comment