[Answer]-Extra context with django-registration

1👍

By adding django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS (which comes by default) you should have a request instance on the templates. You can then access the user (which may be an authenticated User or an AnonymousUser, never None) on your templates by typing:

{% if request.user.is_authenticated %}
👤Poli

0👍

the request object itself is accessible on the html pages

better to use that in your base.html file to access it on all pages like

  {% if request.user.is_authenticated %}   

0👍

Am using django 1.4 and apparently request is not a default context. Or as it is I could not access request by default so I added this to my settings.py and it worked for me

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.contrib.messages.context_processors.messages",
"django.core.context_processors.request",)

Of course in my case I only needed "django.core.context_processors.request" but since I am overriding the default context processors, I need to add them manually in my settings

👤Baama

Leave a comment