LoginView does not seem to work

Hi guys, I am following the example from Django for Beginner by William S. Vincent.

I am trying to add a log in page using the built-in LoginView.

I have the added a urlpattern to config/urls.py:

from django.contrib import admin

from django.urls import path, include

urlpatterns = [

    path('admin/', admin.site.urls),

    path('', include('blog.urls')),

    path('accounts/', include('django.contrib.auth.urls')),


I have created a new template file, templates/registration/login.html as follows:

{% extends 'base.html' %}

{% block content %}

    <h2>Log In</h2>

    <form method="'post">

        {% csrf_token %}

        {{ form.as_p }}

        <button type="submit">Log In</button>


{% endblock content %}

And finally I added LOGIN_REDIRECT_URL = 'home' to config/settings.py.

I logged out via the localhost:8000/admin page. Then I navigated to localhost:8000/accounts/login and enter the user and password.

I see this in the terminal: [03/Apr/2022 16:20:59] “GET /accounts/login/?csrfmiddlewaretoken=LdjbrxGnie8ZQpCkyvYpd97FATAxGSFrRb24oKAcjzYeUfR0Cxf9A6RIdcCL7NBZ&username=admin&password=password HTTP/1.1” 200 1253

I didn’t not see an error or password error. I am not logged in and I did not get redirected to the home page. The version of Django I am using is 3.1.0. Can you please help and see if I am missing something?

Thank you very much for your help in advance!

You’ve got an extra apostrophe in your form tag:

Should be <form method="post">

@KenWhitesell, thank you!

That solved the problem!