Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

urls.py

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'),

]

views.py

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

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

login.html

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

>Solution :

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

Try this:


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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading