From ef8ae06c2acd7b3673fee15b379213169153c7b0 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 17 Oct 2024 14:38:05 -0400 Subject: [PATCH] Fixed #35903 -- Made admin's "view on site" URL accept non-integer ContentType pks. --- django/contrib/admin/sites.py | 2 +- tests/admin_views/tests.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index dc67262afc..3399bd87b8 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -282,7 +282,7 @@ class AdminSite: path("autocomplete/", wrap(self.autocomplete_view), name="autocomplete"), path("jsi18n/", wrap(self.i18n_javascript, cacheable=True), name="jsi18n"), path( - "r///", + "r///", wrap(contenttype_views.shortcut), name="view_on_site", ), diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index c5d8b8f4f6..3f106f6814 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -8664,6 +8664,19 @@ class AdminViewOnSiteTests(TestCase): ), ) + def test_view_on_site_url_non_integer_ids(self): + """The view_on_site URL accepts non-integer ids.""" + self.assertEqual( + reverse( + "admin:view_on_site", + kwargs={ + "content_type_id": "37156b6a-8a82", + "object_id": "37156b6a-8a83", + }, + ), + "/test_admin/admin/r/37156b6a-8a82/37156b6a-8a83/", + ) + @override_settings(ROOT_URLCONF="admin_views.urls") class InlineAdminViewOnSiteTest(TestCase):