Skip to content

Comments

swev-id: django__django-16612 — Preserve query string in AdminSite.catch_all_view redirect#509

Open
casey-brooks wants to merge 1 commit intodjango__django-16612from
fix/admin-catch-all-querystring
Open

swev-id: django__django-16612 — Preserve query string in AdminSite.catch_all_view redirect#509
casey-brooks wants to merge 1 commit intodjango__django-16612from
fix/admin-catch-all-querystring

Conversation

@casey-brooks
Copy link

Fixes #507

Reproduction

  1. .venv/bin/python tests/runtests.py admin_views.test_adminsite.SiteAppendSlashRedirectTests.test_catch_all_preserves_querystring_on_slash_redirect

Observed failure:

FAIL: test_catch_all_preserves_querystring_on_slash_redirect (admin_views.test_adminsite.SiteAppendSlashRedirectTests.test_catch_all_preserves_querystring_on_slash_redirect)
----------------------------------------------------------------------
Traceback (most recent call last):
  File \"/workspace/django/tests/admin_views/test_adminsite.py\", line 127, in test_catch_all_preserves_querystring_on_slash_redirect
    self.assertEqual(resp[\"Location\"], \"/test_admin/admin/auth/?id=123\")
AssertionError: '/test_admin/admin/auth/' != '/test_admin/admin/auth/?id=123'

Fix

  • Redirect using request.get_full_path(force_append_slash=True) so the querystring is preserved.
  • Add a regression test enforcing the behavior when APPEND_SLASH is True.
  • Regression was introduced in ba31b01.

Testing

  • .venv/bin/python tests/runtests.py admin_views.test_adminsite.SiteAppendSlashRedirectTests.test_catch_all_preserves_querystring_on_slash_redirect

@casey-brooks casey-brooks requested a review from a team December 24, 2025 16:55
@casey-brooks
Copy link
Author

Test & Lint Summary

  • .venv/bin/python tests/runtests.py admin_views.test_adminsite.SiteAppendSlashRedirectTests.test_catch_all_preserves_querystring_on_slash_redirect: 1 passed, 0 failed, 0 skipped
  • .venv/bin/flake8 django/contrib/admin/sites.py tests/admin_views/test_adminsite.py: no lint issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The redirect now uses request.get_full_path(force_append_slash=True), which preserves query strings while still normalizing the trailing slash, and the regression test covers the failure case from the issue.

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@rowan-stein rowan-stein changed the base branch from django__django-16612 to main January 11, 2026 20:45
@rowan-stein rowan-stein changed the base branch from main to django__django-16612 January 12, 2026 20:14
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.

AdminSite.catch_all_view() drops query string in redirects

3 participants