Hello,

I believe its a simple typo!

authenticate(user=usuario, password=clave)

should be

authenticate(username=usuario, password=clave)

Regards

On Sun, Aug 19, 2012 at 3:35 PM, Jorge Garcia <jorgegarcia...@gmail.com>wrote:

> Hi there. Im doing my first login form for an existing Django application.
> The thing is that when I give the correct usr/pswd from the
> web,  django.contrib.auth.authenticate returns systematically None.
> However, when I try the same thing from the Django shell it works.  I'm
> working with a "john" user created from the Django admin application, using
> the "password chang" form. Here's the code, and the Django command line
> output.
>
> My application and me will be eternally thankful for your help.
>
> ++COMMAND LINE
> python manage.py shell
> >>> from django.contrib.auth import authenticate
> >>> user = authenticate(username='john', password='johnpassword')
> >>> print user
> john
>
> ++VIEWS.PY
> from django.contrib.auth.models import User
>
> def index(request):
>     return render_to_response('unoporuno/index.html', None,
> context_instance=RequestContext(request))
>
> def login_cidesal(request):
>     usuario = request.POST['usuario']
>     clave = request.POST['clave']
>     user = authenticate(user=usuario, password=clave)
>     return HttpResponse("logging in user:" + usuario + " with password:" +
> clave + " and authenticate result=" + str(user))
>
> ++URLS.PY
> urlpatterns = patterns('unoporuno.views',
>                    url(r'^$','index'),
>                    url(r'login/', 'login_cidesal'),
>
> ++INDEX.HTML
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="es">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
> <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}style1.css"/>
> </head>
> <body>
> <form method="post" action="/unoporuno/login/">
> {% csrf_token %}
> <div align="center">
> <img src="{{ STATIC_URL }}cidesal.jpg" height="140" width="140"
> border="0"/>
> <h1>UnoporunO</h1>
> <h4>Buscador de personas especializado en movilidad profesional</h4>
> <br/>
> Usuario: <input type="text" name="usuario" size="16" /><br/><br/>
> Clave : <input type="password" name="clave" size="16" /><br/>
> <p><input type="submit" value="Login" /></p>
> </div>
> </body>
> </html>
>
> ++WEB RESULT TYPING usuario=john clave=johnpassword
> logging in user:john with password:johnpassword and authenticate
> result=None
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/1UKsQlJ5OB8J.
> 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.
>

-- 
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.

Reply via email to