def login_view(request): if request.method == "POST": form = AuthenticateForm(data=request.POST) if form.is_valid(): login(request, form.get_user()) #Success return redirect('/')
def login_view(request): if request.method == 'POST': form = AuthenticateForm(data=request.POST) if form.is_valid(): login(request, form.get_user()) return redirect('/') else: return index(request, auth_form=form)
def login_view(request): #logs the user in if request.method == 'POST': # expects a HTTP POST request for the login (since the form's method is POST) form = AuthenticateForm(data=request.POST) if form.is_valid(): #If form validation is successful, login the user using the login() method which starts the session and then redirects to the root url. login(request, form.get_user()) # Success return redirect('/') else: # Failure return index(request, auth_form=form) #pass the instance of the auth_form received from the user to the index function and list the errors return redirect('/') #if the request isn't POST then the user is redirected to the root url
def login_view(request): if request.method == 'POST': form = AuthenticateForm(data=request.POST) if form.is_valid(): login(request, form.get_user()) # Success return redirect('/') else: # Failure return index(request, auth_form=form) return redirect('/')