Created
January 18, 2014 06:04
-
-
Save chibiegg/8486811 to your computer and use it in GitHub Desktop.
views.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding=utf-8 | |
from django.contrib.auth.forms import AuthenticationForm | |
from django.contrib.auth import login | |
from django.shortcuts import redirect, render | |
def login_view(request): | |
if request.method == "POST": | |
form = AuthenticationForm(request.POST) | |
if form.is_valid(): | |
user = form.get_user() | |
login(request, user) | |
return redirect("index") | |
else: | |
form = AuthenticationForm() | |
return render(request, "login.html", {"form":form}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment