Method Not Allowed (GET): /accounts/logout/

there is an issue in Django with the LogoutView. when I put the link 'accounts/logout' it prompts in the cmd "GET /accounts/logout/ HTTP/1.1" 405 0 Method Not Allowed (GET): /accounts/logout/ Method Not Allowed: /accounts/logout/. this is the urlpatterns:

urlpatterns = [
    path('', include('django.contrib.auth.urls')),
    path('login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'),
    path('profile/', showProfile, name='profile'),
    path('logout/', auth_views.LogoutView.as_view(template_name='registration/logged_out.html'), name='logout'),
]

and this is the 'registration/logged_out.html' file content:

{% extends "generic_base.html" %}

{% block content %}
    <form method="post" action="{% url 'user:logout' %}">
        {% csrf_token %}
        <button type="submit">Logout</button>
    </form>
{% endblock content %}

I saw a lot of ways to fix this. but none of them worked.

Back to Top