farridav/django-jazzmin

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

Closed this issue · 6 comments

While logging out the admin, rather than performing a POST the template performs a GET operation which raises an error saying:

Method Not Allowed (GET): /admin/logout/
Method Not Allowed: /admin/logout/
GET /admin/logout/ HTTP/1.1" 405 0

  • Issue is in /jazzmin/templates/admin/base.html --- and search for logout then,

  • change this
    <a href="{% url 'admin:logout' %}" class="dropdown-item">
    <i class="fas fa-users mr-2"></i> {% trans 'Log out' %}
    </a>

  • to this
    <form action="{% url 'admin:logout' %}" method="post">
    {% csrf_token %}
    <button type="submit" class="dropdown-item">
    <i class="fas fa-users mr-2"></i> {% trans 'Log out' %}
    </button>
    </form>

the view:

def logout_user(request):
    logout(request)
    return redirect('admin:index')

the modified line of base.html:
<a href="{% url 'jazzmin_dev:logout' %}" class="dropdown-item">

Hi @8bitaby, a PR was merged today (#544) to fix this issue. A new release will be needed to release this fix.

@jamesgilmorelyst When will this be sorted? I have just installed the new version but still it aint wworking as working expected. Throwing the same error

i am also getting the same error

Method Not Allowed: /admin/logout/
2024-04-18 20:39:06,142 - 61980 - log.py-log:241 - WARNING: Method Not Allowed: /admin/logout/
[18/Apr/2024 20:39:06] "GET /admin/logout/ HTTP/1.1" 405 0

Apologies for the delay, but we've release the fix to resolve the logout issue now:

If you are still supporting an older version of Python (<3.8) or Django (<4) then we also have release a fix for this version as well: