1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #9602 -- Added AdminSite.get_model_admin().

This allows retrieving an admin class for the given model class without
using internal attributes.
This commit is contained in:
Mariusz Felisiak
2023-07-07 08:06:01 +02:00
committed by GitHub
parent d569c1dcfe
commit f64fd47a76
15 changed files with 127 additions and 69 deletions

View File

@@ -878,7 +878,7 @@ class ChangeListTests(TestCase):
user_parents = self._create_superuser("parents")
# Test with user 'noparents'
m = custom_site._registry[Child]
m = custom_site.get_model_admin(Child)
request = self._mocked_authenticated_request("/child/", user_noparents)
response = m.changelist_view(request)
self.assertNotContains(response, "Parent object")
@@ -903,7 +903,7 @@ class ChangeListTests(TestCase):
# Test default implementation
custom_site.register(Child, ChildAdmin)
m = custom_site._registry[Child]
m = custom_site.get_model_admin(Child)
request = self._mocked_authenticated_request("/child/", user_noparents)
response = m.changelist_view(request)
self.assertContains(response, "Parent object")