summaryrefslogtreecommitdiff
path: root/tests/admin_checks/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_checks/tests.py')
-rw-r--r--tests/admin_checks/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index 864609a6c7..7e1902105f 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -667,3 +667,20 @@ class SystemChecksTestCase(TestCase):
)
]
self.assertEqual(errors, expected)
+
+ def test_list_filter_works_on_through_field_even_when_apps_not_ready(self):
+ """
+ Ensure list_filter can access reverse fields even when the app registry
+ is not ready; refs #24146.
+ """
+ class BookAdminWithListFilter(admin.ModelAdmin):
+ list_filter = ['authorsbooks__featured']
+
+ # Temporarily pretending apps are not ready yet. This issue can happen
+ # if the value of 'list_filter' refers to a 'through__field'.
+ Book._meta.apps.ready = False
+ try:
+ errors = BookAdminWithListFilter.check(model=Book)
+ self.assertEqual(errors, [])
+ finally:
+ Book._meta.apps.ready = True