This is my logged_out.html
{% extends 'base.html' %} {% block title %} Logout {% endblock %} {% block content %} <form action="{% url 'login' %}", method="POST"> {% csrf_token %} <button type="submit">Logout</button> </form> {% endblock %} This is my urls.py file
urlpatterns = [ ... path('accounts/', include("django.contrib.auth.urls")), path('accounts/logout/', auth_views.LogoutView.as_view(template_name='logged_out.html'), name='logout'), ] view.py
@require_POST def user_logout(request): logout(request) return render(request, "registration/logged_out.html", {}) I've followed the docs to make the /logout a POST and I still get 405 error saying it's a GET request. How do I solve this?
<form action="{% url 'login' %}", method="POST">This form is confusing. The button says "Logout", but it sends you to theloginurl??action="...",? That does not belong.