On Oct 4, 2005, at 8:42 AM, Andreas wrote:
What's the best way to check if a user is logged in on every page
(read: view) of a website? I'd like to be able to display the username
in the template if a user is logged in. At the moment, I'm using the
following code:

If you use django.core.extensions.DjangoContext instead of django.core.template.Context the {{ user }} variable will automatically be available in your templates. If {{ user.is_anonymous }} is True then the user is *not* logged in; otherwise the user info is available as {{ user.username }}, {{ user.email }}, etc.

Jacob

Reply via email to