Hello,

Being brand new to Django I'm trying to write an authentification
page.
I used the example from the Django book and tried it myself.
Unfortunatly Iit does not work.

--------------------------------------------------------------------------------------
My urls.py

from django.conf.urls.defaults import *
from fac import views

urlpatterns = patterns('',

    (r'^welcome/$', views.welcome),
    (r'^login/$', views.login),
    (r'^test/$', views.test),
)
---------------------------------------------------------------------------------------

views.py

from django.shortcuts import render_to_response
from django.contrib import auth

def welcome(request):
    return render_to_response('fac_login.html')

def login(request):
    username = request.POST.get('username')
    password = request.POST.get('password')
    user = auth.authenticate(username=username, password=password)

    if user is not None and user.is_active:
        # Correct password, and the user is marked "active"
        auth.login(request, user)
        return HttpResponse("Password correct")

    else:
        return HttpResponse("Password incorrect or nothing
entered")



def test(request):
     return HttpResponse("Hello, world. This is the FAC test page.")
------------------------------------------------------------------------------------------------------------

This is also the structure of the example.
In the fac_login.html is have my Form that takes a password and user
name.

-----------------------------------------------------------------------------------------------------------
fac_login.hml

{% extends "base.html" %}

{% block content %}

   {% if form.errors %}
      <p class="error">Sorry, that's not a valid username or password</
p>
   {% endif %}

      <form action='.' method='post'>
      <label for="username">User name:</label>
      <input type="text" name="username" value="" id="username">
      <label for="password">Password:</label>
      <input type="password" name="password" value="" id="password">
      <input type="submit" value="login">
      </form>
{% endblock %}

---------------------------------------------------------------------------------------------------------

When I now start the test server and type the the url login into my
browser
I always get an "Password incorrect"
but my login page with the usernam and password field is never shown.
but wghen i type welcome url to my browser I see the page and can
enter a
username and password but nothing happens when I click the login
button.

How do I tell django to call the fac_login page first. and then when I
click the login button it
executes the login view?

lg
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-us...@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