1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +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

@@ -152,10 +152,10 @@ class TestRelatedFieldsAdminOrdering(TestCase):
site.unregister(Band)
def check_ordering_of_field_choices(self, correct_ordering):
fk_field = site._registry[Song].formfield_for_foreignkey(
fk_field = site.get_model_admin(Song).formfield_for_foreignkey(
Song.band.field, request=None
)
m2m_field = site._registry[Song].formfield_for_manytomany(
m2m_field = site.get_model_admin(Song).formfield_for_manytomany(
Song.other_interpreters.field, request=None
)
self.assertEqual(list(fk_field.queryset), correct_ordering)