def LoginRequest(request):
active = "index"
message = ""
if request.user.is_authenticated():
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
else:
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
username = form.cleaned_data['email']
password = form.cleaned_data['password']
user = authenticate(username=username,password=password)
if user is not None and user.is_active:
login(request,user)
return HttpResponseRedirect('/dashboard')