diff options
| author | Daniel Pyrathon <pirosb3@gmail.com> | 2015-02-10 18:15:54 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-10 19:55:06 -0500 |
| commit | 19188826b4aa989475418f1ea9bf8631b04da1e8 (patch) | |
| tree | 0a005a39819ae21875ea7f6b3eaecb4ece219662 /tests/admin_checks/tests.py | |
| parent | 1fbe8a2de334bfec5e9b77e36f8a3c1cf2cd70be (diff) | |
Fixed #24146 -- Allowed model._meta.get_field() to be used after apps.models_ready
Diffstat (limited to 'tests/admin_checks/tests.py')
| -rw-r--r-- | tests/admin_checks/tests.py | 17 |
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 |
