On Thu, Jun 23, 2011 at 8:28 AM, Travis Bear <travis.b...@gmail.com> wrote:
> Hi,
>
> I'm using the django.contrib.auth app to manage user login/logout.  I
> can successfully log in and out, but I cannot access the {{ user }}
> object in my templates.  If I'm reading these documents correctly,
> that should be enabled by default:
>
>    @ zalun
>    
> http://stackoverflow.com/questions/41547/always-including-the-user-in-the-django-template-context
>
>   
> https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-data-in-templates
>
> Am I missing something?  Here is a snippet from my base.html:
>
> {% if user.is_authenticated %}
>    <p>Welcome, {{ user.username }}. Thanks for logging in.</p>
> {% else %}
>    <p>Welcome, new user. Please log in.</p>
> {% endif %}
>
> If I I have my view explicity include the request.user object in the
> template context, the above code works as expected.  But I don't want
> to have to put this in every one of my view functions.
>
> Here are the template context processors in my 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",
> )
>
> Any insights appreciated.
>

<psychic>
You aren't rendering the template with a RequestContext, so
TEMPLATE_CONTEXT_PROCESSORS doesn't come into play.
</psychic>

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to