diff --git a/AUTHORS b/AUTHORS index 1041e2a631..a9cddfd4b1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -564,6 +564,7 @@ answer newbie questions, and generally made Django that much better: Karderio Karen Tracey Karol Sikora + Kasun Herath Katherine “Kati” Michel Kathryn Killebrew Katie Miller diff --git a/tests/admin_views/test_adminsite.py b/tests/admin_views/test_adminsite.py index 68a32567d8..7c4841f916 100644 --- a/tests/admin_views/test_adminsite.py +++ b/tests/admin_views/test_adminsite.py @@ -11,8 +11,19 @@ site = admin.AdminSite(name="test_adminsite") site.register(User) site.register(Article) + +class CustomAdminSite(admin.AdminSite): + site_title = "Custom title" + site_header = "Custom site" + + +custom_site = CustomAdminSite(name="test_custom_adminsite") +custom_site.register(User) + + urlpatterns = [ path("test_admin/admin/", site.urls), + path("test_custom_admin/admin/", custom_site.urls), ] @@ -43,6 +54,13 @@ class SiteEachContextTest(TestCase): self.assertEqual(ctx["site_url"], "/") self.assertIs(ctx["has_permission"], True) + def test_custom_admin_titles(self): + request = self.request_factory.get(reverse("test_custom_adminsite:index")) + request.user = self.u1 + ctx = custom_site.each_context(request) + self.assertEqual(ctx["site_title"], "Custom title") + self.assertEqual(ctx["site_header"], "Custom site") + def test_each_context_site_url_with_script_name(self): request = self.request_factory.get( reverse("test_adminsite:index"), SCRIPT_NAME="/my-script-name/"