Skip to content

nav: log out with POST, as required by Django 5 - #789

Merged
drnlm merged 2 commits into
CTPUG:masterfrom
rabumaabraham:fix-logout-post
Oct 27, 2026
Merged

drnlm merged 2 commits into
CTPUG:masterfrom
rabumaabraham:fix-logout-post

Conversation

@rabumaabraham

Copy link
Copy Markdown
Contributor

Since Django 5.0, LogoutView only accepts POST requests. The "Log
out" item in the user menu is still a plain link (GET), so clicking it
gives an HTTP 405 and the user stays logged in.

This replaces the link with a small form that POSTs to auth_logout
(with a CSRF token), using the dropdown-item class so it looks the
same as the other menu items.

Added tests checking that the menu uses a POST form, and that POSTing
to logout logs the user out.

The same fix for wafer-debconf's own menu, which overrides this one, is
in https://salsa.debian.org/debconf-team/public/websites/wafer-debconf/-/merge_requests/294

(issue https://salsa.debian.org/debconf-team/public/websites/wafer-debconf/-/issues/84).

Before After
before after

Since Django 5.0, LogoutView only accepts POST requests, so the "Log
out" link in the user menu fails with HTTP 405. Replace it with a small
form that POSTs to auth_logout, styled as a dropdown item.
@stefanor

Copy link
Copy Markdown
Member

Thanks for writing tests, but I'm really not convinced about the value of any of these tests. The functionality isn't in wafer, it's in Django.

They test Django's LogoutView rather than wafer.
@rabumaabraham

Copy link
Copy Markdown
Contributor Author

Thanks for writing tests, but I'm really not convinced about the value of any of these tests. The functionality isn't in wafer, it's in Django.

@stefanor Thanks, I've dropped the tests.

@drnlm
drnlm merged commit 7e06962 into CTPUG:master Oct 27, 2026
80 of 88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants