[Django] #36575: Document logout link workaround with a better URL name

2 views
Skip to first unread message

Django

unread,
Aug 26, 2025, 9:08:06 PMAug 26
to django-...@googlegroups.com
#36575: Document logout link workaround with a better URL name
--------------------------+-----------------------------------------
Reporter: adehnert | Type: Uncategorized
Status: new | Component: Documentation
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------+-----------------------------------------
The Django 4.1 release notes mention:

If you want to retain the user experience of an HTML link, you can use
a form that is styled to appear as a link:
{{{
<form id="logout-form" method="post" action="{% url 'admin:logout'
%}">
{% csrf_token %}
<button type="submit">{% translate "Log out" %}</button>
</form>
}}}

However, the `admin:logout` view appears to require the the user have
admin access (at least, empirically, my user that doesn't gets redirected
to `/admin/` and then `/admin/login/`). The plain `logout` URL name
(https://docs.djangoproject.com/en/5.2/topics/auth/default/#django.contrib.auth.views.LogoutView),
which doesn't require this, seems like a better fit.

(Relatedly, this information seems pretty timeless -- should it be
included in say the docs for LogoutView, rather than just some
increasingly-old release notes? Presumably somebody writing a brand-new
Django 5.2 app *also* wants to know how to make a logout link. I spent a
bit looking around the docs and don't see it mentioned anywhere --
actually, I was a little surprised that the tutorial doesn't obviously
mention extending base templates and provide a sample template with a
login link, logout link, etc..)
--
Ticket URL: <https://code.djangoproject.com/ticket/36575>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 26, 2025, 9:33:20 PMAug 26
to django-...@googlegroups.com
#36575: Document logout link workaround with a better URL name
-------------------------------+--------------------------------------
Reporter: adehnert | Owner: (none)
Type: Uncategorized | Status: new
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by adehnert):

I also argue in #36576 that `admin:logout` *should* work for logging out
non-admin users, but I contend that using `admin:logout` *here* is wrong
independent of that. If nothing else, it appears that
[https://docs.djangoproject.com/en/5.2/topics/auth/default/#django.contrib.auth.logout
`auth.logout`] and
[https://docs.djangoproject.com/en/5.2/ref/contrib/admin/#django.contrib.admin.AdminSite.logout_template
the admin variant] can use different templates, and presumably most people
following these directions to add a logout link are doing it outside the
admin context -- the admin has a logout link provided. That said, it's
obviously much worse because of #36576 (I only noticed the discrepancy
when I finally went to log out a user without admin access, and that
wouldn't have been relevant without #36576).
--
Ticket URL: <https://code.djangoproject.com/ticket/36575#comment:1>
Reply all
Reply to author
Forward
0 new messages