--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y4Lg1ZkqDA4TR7RuV6z-gutuKmzFZ%2BvpQsr%3DUnqXV2OkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
On Friday 05 May 2017 10:03:47 sum abiut wrote:
> i have try to login user using the guide from
> https://docs.djangoproject.com/en/1.11/topics/auth/default/
>
> but get an error. Can someone advise what i am doin wrong here
It's a flaw in the docs.
It assumes that by now you are familiar with function-based views and how to write them for forms processing.
The code below splits the GET part (rendering the form) and the POST part (processing the form) and you're only shown the POST part. It assumes you already have another view function that renders the form or that the login form is part of many other pages.
> he is my view.py
>
> #Authentication user
> def login(request):
> username=request.POST['username']
> password=request.POST['password']
> user=authenticate(request,username=username,password=password)
> if user is not None:
> login(request,user)
> #Redirect to dashboard page
> return render(request,'dashboard.html')
> else:
> # return invalid login message
> return HttpResponse( 'You have enter a wrong password or
> username please again')
--
Melvyn Sopacua