I have a problem with my login template. I´m not sure, but I think I´m using a custom form since the path is templates/registration/login.html . So, I think it gets replaced to the usual django form. But the input fields of my form dont show up, so I only have the login button and some text underneath it. Similar questions I read couldn´t solve it, so I hope someone can me help here. If you need any code more, please let me know. Thanks in advance.
views.py
def login(response):
if response.method == "POST":
form = LoginForm(response.POST)
if form.is_valid():
username = form.cleaned_data.get("username")
password = form.cleaned_data.get("password")
user = authenticate(username=username, password=password)
auth_login(response,user)
return redirect("home")
else:
form = LoginForm()
return render(response, "registration/login.html",{})
urls.py
from register import views as v
path("", v.login, name="login"),
login.html
{% block content %}
<form method="POST">
{% csrf_token %}
<div class="content">
<h3>{{form.username}}</h3>
<h3>{{form.password}}</h3>
<button type="submit">Login</button>
</div>
</form>
<br>
<p>Don´t have an account yet?</p>
<p>Create one <a href="/signup">here</a></p>
{% endblock %}
The render() function takes the request object as its first argument, a template name as its second argument and a dictionary as its optional third argument.
so, you should pass {"form": form}
as the third argument to the render function.