def login_action request if request method POST username request POST

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def login_action(request):
if request.method == 'POST':
username = request.POST['login']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponse("You was successfuly logged in!")
else:
return HttpResponse("Fail of login!")