summaryrefslogtreecommitdiff
path: root/tests/admin_changelist
diff options
context:
space:
mode:
authorldeluigi <44567586+ldeluigi@users.noreply.github.com>2024-09-11 09:04:46 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-09-11 10:41:23 +0200
commit2a4321ba23042c962f8dc966779239244c6e4402 (patch)
treea129d0eec62f9443ed9a8d31bc43d3114e1631d5 /tests/admin_changelist
parent371a9f3c5f24c792ce61b36c132772470f444029 (diff)
Fixed #35747 -- Used default ordering when the ORDER_VAR param is blank in the admin changelist.
Diffstat (limited to 'tests/admin_changelist')
-rw-r--r--tests/admin_changelist/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
index 694f807781..d8055a809b 100644
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -1328,6 +1328,20 @@ class ChangeListTests(TestCase):
UnorderedObjectAdmin.ordering = ["id", "bool"]
check_results_order(ascending=True)
+ def test_ordering_from_model_meta(self):
+ Swallow.objects.create(origin="Swallow A", load=4, speed=2)
+ Swallow.objects.create(origin="Swallow B", load=2, speed=1)
+ Swallow.objects.create(origin="Swallow C", load=5, speed=1)
+ m = SwallowAdmin(Swallow, custom_site)
+ request = self._mocked_authenticated_request("/swallow/?o=", self.superuser)
+ changelist = m.get_changelist_instance(request)
+ queryset = changelist.get_queryset(request)
+ self.assertQuerySetEqual(
+ queryset,
+ [(1.0, 2.0), (1.0, 5.0), (2.0, 4.0)],
+ lambda s: (s.speed, s.load),
+ )
+
def test_deterministic_order_for_model_ordered_by_its_manager(self):
"""
The primary key is used in the ordering of the changelist's results to