mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Fixed #35265 -- Added AdminSite tests for changing titles.
This commit is contained in:
parent
c187417611
commit
f5ed4306bb
1
AUTHORS
1
AUTHORS
@ -564,6 +564,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Karderio <karderio@gmail.com>
|
||||
Karen Tracey <kmtracey@gmail.com>
|
||||
Karol Sikora <elektrrrus@gmail.com>
|
||||
Kasun Herath <kasunh01@gmail.com>
|
||||
Katherine “Kati” Michel <kthrnmichel@gmail.com>
|
||||
Kathryn Killebrew <kathryn.killebrew@gmail.com>
|
||||
Katie Miller <katie@sub50.com>
|
||||
|
@ -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/"
|
||||
|
Loading…
Reference in New Issue
Block a user