Answer the question
In order to leave comments, you need to log in
Why don't the passwords match?
Hello!
Now I'm learning janga and a strange problem has appeared. When you try to log in to your account or register, it doesn't work
When registering, an error occurs - password_mismatch Attention! even if the passwords were not entered, but inserted CTRL + V
When authorizing into an existing account, the error is invalid_logininactive
Files:
from django.contrib.auth import login
from django.http import HttpResponse
from django.shortcuts import render
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
def user_login(request):
if request.method == "POST":
form = AuthenticationForm()
if form.is_valid():
usr = form.get_user()
login(request, usr)
return HttpResponse("<h1>good</h1>")
else:
return HttpResponse(form.error_messages)
else:
form = AuthenticationForm()
return render(request, "UserAuth/login.html", {"form": form})
def user_register(request):
if request.method == "POST":
form = UserCreationForm()
if form.is_valid():
usr = form.save()
login(request, usr)
return HttpResponse("<h1>good</h1>")
else:
return HttpResponse(form.error_messages)
else:
form = UserCreationForm()
return render(request, "UserAuth/register.html", {"form": form})
from django.urls import path
from .views import *
urlpatterns = [
path("login/", user_login),
path("register/", user_register),
]
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Log in</title>
</head>
<body>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Go</button>
</form>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Go</button>
</form>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question