Re: authenticate() not working

32 views
Skip to first unread message

aRkadeFR

unread,
Mar 30, 2015, 9:46:31 AM3/30/15
to django...@googlegroups.com
Hello,


Just by changing the type of your input, you're enable to
authenticate inside your view then?

Do a dump of your post data to see if anything has changed.
```
print("data: {!s}".format(request.POST))
```

Then you can see in a shell (manage.py shell) if the authenticate
function works as expected with your data.

On 03/28/2015 10:36 AM, Kishan Mehta wrote:
Hi all,

>>My html has following input type :

Password: <input type="password" name="password" value="" size="50" />


>>  user = authenticate(username=username, password=password)
is not able to authenticate in views.py...

Not able to login.

P.S :
when i do :

<input type="text"  ....

authentication works...

Please help.
New to django.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9b40bc4f-09ad-4697-b2a7-5d4881acd496%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Zárate

unread,
Apr 4, 2015, 11:01:01 PM4/4/15
to django...@googlegroups.com
It's because you need to login the user (authenticate don't login only get the user )

It's something like this:
from django.contrib.auth import authenticate, login

def my_view(request):
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            login(request, user)
            # Redirect to a success page.
        else:
            # Return a 'disabled account' error message
            ...
    else:
        # Return an 'invalid login' error message.
        ...
 


For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


Luis Zárate

unread,
Apr 4, 2015, 11:02:00 PM4/4/15
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages