diff options
| author | Andreas Pelme <andreas@pelme.se> | 2018-02-16 03:00:31 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-15 21:00:31 -0500 |
| commit | e307ff29d28737d5a764ce2fa7db010231d6fc8e (patch) | |
| tree | ac6cf4a88d36e5cb5de2c7a28f32a55ded650bfa /tests/admin_views/tests.py | |
| parent | d368784bacc7e58b426f29937ee842aa14d439ad (diff) | |
Fixed #27810 -- Allowed query expressions in admin_order_field.
Diffstat (limited to 'tests/admin_views/tests.py')
| -rw-r--r-- | tests/admin_views/tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 54a0590d21..8cdaa2c9a8 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -349,6 +349,32 @@ class AdminViewBasicTest(AdminViewBasicTestCase): "Results of sorting on callable are out of order." ) + def test_change_list_sorting_callable_query_expression(self): + """ + Query expressions may be used for admin_order_field. (column 9 is + order_by_expression in ArticleAdmin). + """ + response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '9'}) + self.assertContentBefore( + response, 'Oldest content', 'Middle content', + 'Results of sorting on callable are out of order.' + ) + self.assertContentBefore( + response, 'Middle content', 'Newest content', + 'Results of sorting on callable are out of order.' + ) + + def test_change_list_sorting_callable_query_expression_reverse(self): + response = self.client.get(reverse('admin:admin_views_article_changelist'), {'o': '-9'}) + self.assertContentBefore( + response, 'Middle content', 'Oldest content', + 'Results of sorting on callable are out of order.' + ) + self.assertContentBefore( + response, 'Newest content', 'Middle content', + 'Results of sorting on callable are out of order.' + ) + def test_change_list_sorting_model(self): """ Ensure we can sort on a list_display field that is a Model method |
