Looks like you are not making anything very custom on you view so maybe 
would be easier/better to use the buitin views from django auth.

on your urls.py you can do:

from django.contrib.auth import views as auth_views

urlpatterns = [
    ...
    url(r'^login/', auth_views.login),
]

On your settings.py:
LOGIN_URL = '/login' #the global address of the login page(loguin_required 
decorators, etc will redirect to here)
NEXT_PAGE = '/home' #page the user is redirected after login


On Wednesday, November 4, 2015 at 12:51:02 AM UTC-5, Dariusz Mysior wrote:
>
> I try do login view and I find it on 
>
> https://docs.djangoproject.com/en/1.8/topics/auth/default/
>
> 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.
>         ...
>
>
>
> to give request.POST username and password and username I must create my 
> own form or maybe Django have that form ready? I use Django 1.8
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/91465324-db83-4850-8460-b54ab8ef4542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to