1 year ago
#75909

refia
Can't login while data is true and login button seems doesn't work
I make authentication app which is register and login with email and password using django and when I run my app the button login is not responding and then back to login page
I have tried to create new account and it saved on database (I use DBBrowser SqLite app) but when I want to do login then the login button is not working
this is views.py
def login_request(request):
if request.method == "POST":
form = FormPengguna(request.POST)
if form.is_valid():
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
user = authenticate(email=email, password=password)
if user is not None:
login(request, user)
messages.info(request, "Berhasil Login")
return redirect("halaman_utama:homepage")
else:
messages.error(request, "Email/Password Salah!")
form = FormPengguna()
print(request.POST)
return render(request=request, template_name="masuk.html", context={"form": form})
this is html code
<form method="POST" action="/login_request" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group row">
<label class="col-sm-2 col-form-label">Email :</label>
<div class="col-sm-4">
{{ form.email }}
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Password :</label>
<div class="col-sm-4">
{{ form.password }}
</div>
</div>
<button class="btn btn-primary" type="submit">Login</button>
</form>
<br><br><br>
<p class="text-center">Forgot Password? <a href="/password_reset_request">Click Here</a>.</p>
python
python-3.x
django
forms
authentication
0 Answers
Your Answer