Why is my django web-app login form not working?

I’ve tried to add login form to my tasks web-app, but something goes wrong and I can’t login to my created admin user. After click on the login button page just clearing up and my url changes to that. I have no idea how to fix it, help me please.


urlpatterns = [
    path('', TaskList.as_view(), name='tasks'),
    path('login/', CustomLoginView.as_view(), name='login'),
    path('logout/', LogoutView.as_view(next_page='login'), name='logout'),
    path('task/<int:pk>', TaskDetail.as_view(), name='task'),
    path('task-create/', TaskCreate.as_view(), name='task-create'),
    path('task-edit/<int:pk>', TaskUpdate.as_view(), name='task-edit'),
     path('task-delete/<int:pk>', TaskDelete.as_view(), name='task-delete'),



class CustomLoginView(LoginView):
    template_name = 'base/login.html'
    fields = '__all__'
    redirect_authenticated_user = True

    def get_success_url(self):
        return reverse_lazy('tasks')


<form metrhod="POST" action="">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Login">

>Solution :

Could it possibly be a spelling error? metrhod="POST"

Try this:

<form method="POST" action="">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Login">

Leave a Reply