I am quite new to Django and I am trying to create login template. I avoid using crispy-forms to have more control and knowledge on how the data is displayed on website. I am using Django built-in login form. Unfortunately I am stuck, because my current login.html seems to be invalid and nothing happens after sending POST with username and password. This is how it looks like:
login.html
<main class="form-signin">
<form method="post" class="from-group">
<h1 class="display-3 text-center mb-4 fw-normal" style="font-family:'Faster One'; box-shadow: none;">Test</h1>
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
{% csrf_token %}
<div class="form-floating">
<input type="text" class="form-control" id="floatingInput" placeholder="[email protected]">
<label for="floatingInput">Username</label>
</div>
<div class="form-floating mt-3">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Password</label>
</div>
<button class="w-100 btn btn-lg btn-primary" type="submit" value="Log in">Sign in</button>
</form>
</main>
urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home, name='home'),
path('accounts/', include("django.contrib.auth.urls")),
]
views.py
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, render
from poolcar.forms import ReservationForm
@login_required()
def home(request):
return render(request, 'index.html')
[23/Apr/2022 09:59:41] "POST /accounts/login/ HTTP/1.1" 200 2358
[23/Apr/2022 09:59:46] "POST /accounts/login/ HTTP/1.1" 200 2358
POST is sent with 200 OK message, but besides that nothing happens - I am still in the login page, user is not authenticated, validation doesn't work etc. So my question is what I did wrong and how does the mapping between login form/view and html template works exactly?