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

Fixed #24146 -- Allowed model._meta.get_field() to be used after apps.models_ready

This commit is contained in:
Daniel Pyrathon
2015-02-10 18:15:54 +01:00
committed by Tim Graham
parent 1fbe8a2de3
commit 19188826b4
4 changed files with 21 additions and 3 deletions

View File

@@ -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