|
Posted by ferteze |
|
|
Hello,
I'm trying to set up authentication in a Django app relying as much as possible on the provided features, but the login process doesn't yield the expected results. My config is basically as follows : - in my urls.py, I have the following entry :
(r'^login/$', 'django.contrib.auth.views.login',{'template_name' :'login.html'}),
The actual login.html template contains the example login form, the only difference being that it extends my own base template. On the left side of this base template, I have a section showing user related info, and links to the login/logout urls, looking like this :
<div>
<div>{{ user|default:"No user" }}
<div>
{% if user.is_authenticated %}
<div>{{ user.username }}</div>
<div> ...link to logout... </div>
{% else %}
<div> ...link to login...</div>
{% endif %}
</div>
</div>
Now here's what happens. When clicking on the login link, the login form shows up and is capable of authenticating/rejecting the username and the password upon submission. A successful authentication leads back to the welcome page which displays the user information for anonymous users, and not for the authenticated user. However, when subsequently clicking on another link of the welcome page, the user information on the destination page correctly displays the information about the authenticated user. And overall, the logout link seems to work as expected. I should mention that I'm using an LDAP backend to perform authentication, and that, for now, there are no User instances in my Django app. I'm not really a Django expert so any advice is welcome, especially pointers to complete working django apps including authentication. Many thanks. |


