Here is the code for my login form:
<form class="user" action="/returningAgent/" method="post" >
<div class="form-group">
<input type="email" class="form-control form-control-user" id= "InputEmail" name="InputEmail" aria-describedby="emailHelp" placeholder="Enter Email Address...">
</div>
<div class="form-group">
<input type="password" class="form-control form-control-user" id="InputPassword" name="InputPassword" placeholder="Password">
</div>
<div class="form-group">
<div class="custom-control custom-checkbox small">
<input type="checkbox" class="custom-control-input" id="customCheck">
<label class="custom-control-label" for="customCheck">Remember Me</label>
</div>
</div>
<a href="/returningAgent/" class="btn btn-primary btn-user btn-block">
Login
</a>
<hr>
<a href="/returningAgent/" class="btn btn-google btn-user btn-block">
<i class="fab fa-google fa-fw"></i> Login with Google
</a>
<a href="/returningAgent/" class="btn btn-facebook btn-user btn-block">
<i class="fab fa-facebook-f fa-fw"></i> Login with Facebook
</a>
</form>
and here is the code that the form submission triggers:
def returningAgent(request):
#try:
x = Agent.objects.get(bizEmail = request.POST["InputEmail"], password = request.POST["InputPassword"])
diction = {
'f' : x.firstName,
'l' : x.lastName,
'e' : x.bizEmail
}
return render(request, 'index.html', diction)
#except:
#return HttpResponseRedirect('/404/')
I have tried switch request.POST to request.POST.get, and have the name of the field within the HTML form code, yet I still continue to get an error everytime I try to use credentials that are already in my database. Any ideas?
You should update you html form Login
a href
to button i giveerror you actually get in
request.POST.get('InputEmail')
if you print in your view you get this error because data not getting you use a href in login so it will get request and not actual submit formand also see get method dictionary produce this error not actually get data if you want get default data when data not pass by request get default value
get('key name',default value)
so need to update as i gave in
a href
tobutton
then let me what's happened