Wiadomość napisana w dniu 2009-06-01, o godz. 18:50, przez Tim Sawyer: > > You need a RequestContext for the user object to be available in > templates > > http://lincolnloop.com/blog/2008/may/10/getting-requestcontext-your-templates/ > > I use a render_auth method instead of render_to_response, which > automatically > adds the RequestContext to all of my templates. > > Tim. > > On Monday 01 June 2009 17:40:53 K.Berkhout wrote: >> Hi, >> >> Is there a way I can access the "user.is_authenticated" method in >> every view, without having to manually pass the User model to every >> template? Basicly I want to show a login or logout link on every >> page, >> depending on wether the visitor is logged in or not. I've included >> the >> following if statement in my base template: >> >> {% if user.is_authenticated %} >> Welcome {{ user }} , showing logout link... >> {% else %} >> Showing login link... >> {% endif %} >> >> However, it only works with the standard "accounts/login" view, as >> that view has acces to the user.is_authenticated method. >>
For completeness sake: RequestContext *and* django.core.context_processors.auth in TEMPLATE_CONTEXT_PROCESSORS (it's there by default unless one changes configuration). -- Artificial intelligence stands no chance against natural stupidity Jarek Zgoda, R&D, Redefine jarek.zg...@redefine.pl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---