Hi, I'm new to Django and am trying to figure out how to make
authentication work in any view.
First off, I have a base template which has a conditional like this:
{% if user.is_authenticated %}
Yay!
{% else %}
Boo.
{% endif %]
In an accounts/urls.py, I add a line like this:
urlpatterns = patterns('',
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout'),
)
I copied the form from the Djangoprojects page on user authentication
into a registration/login.html template.
When visiting accounts/login for the first time, I get 'Boo.' but if I
login and return to this login page, I get 'Yay.'
If I go to any other view (all of them use the same base template), I
only get 'Boo.'
I looked through django.contrib.auth.views.login, and couldn't find a
'user' variable actually being set. Is this magic? How do I get the
magic to work for all my views?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---