Open CAMM961001 opened 4 months ago
Hi,
This book was originally written for Django ~=4.0.0 so there are some incompatibility issues here. In Django 5, they removed the support for logouts via GET methods. Most likely, you are getting HTTP 405: Method not allowed (GET)
.
Support for logging out via GET requests in the django.contrib.auth.views.LogoutView and django.contrib.auth.views.logout_then_login() is removed. Django Docs
The easiest way of solving this issue is to log out via POST
, which you can do through forms.
<a href="{% url 'logout' %}">Log Out</a>
<form action="{% url 'logout' %}" method="post">
{% csrf_token %}
<button type="submit">Log out</button>
</form>
I hope this answer addresses the issue you are having.
I know this is not the proper channel fot this issue, but I'm not sure where else to go.
For reference I provide my installs, result of pip freezing
django latest
andpsycopg2-binary latest
(20240624):I followed all the steps for user logout in ch6 but failled to logout. When I click logout there seems to be a problem with the LOGOUT_REDIRECT_URL = "home" because it remains redirecting to "accounts/logout".
I found that there is an issue regarding so which seems to be fixed, however I still cannot logout succesfully.
When I switched to the base repos requirements.txt, everything runs properly.