def getLogin(request):
if request.user.is_authenticated:
return redirect('index')
else:
if request.method == "POST":
user = request.POST.get('user')
password = request.POST.get('pass')
auth = authenticate(request, username=user, password=password)
if auth is not None:
login(request, auth)
return redirect('index')
return render(request, "login.html")
<form action="" method="POST">
<div class="form-group">
<label for="email" class="active">Email address</label>
<input type="email" name="email" class="form-control" id="email" placeholder="Enter email">
<div class="email-mg"></div>
</div>
<div class="form-group">
<label for="password" class="active">Password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="Password">
<div class="pass-mg"></div>
</div>
<button type="submit" class="btn btn-primary btn-block waves-effect waves-light" id="loginBtn">Log in</button>
</form>