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



2015-03-30 3:46 GMT-06:00 aRkadeFR <cont...@arkade.info>:

>  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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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
> <https://groups.google.com/d/msgid/django-users/9b40bc4f-09ad-4697-b2a7-5d4881acd496%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/55191B65.4040804%40arkade.info
> <https://groups.google.com/d/msgid/django-users/55191B65.4040804%40arkade.info?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



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

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAG%2B5VyNkjh0ORp1O88--Yxdiq1KCvSVHY_GMfwWkeBfWzXCv8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to