MCPcopy
hub / github.com/django/django / test_specified_ordering

Method test_specified_ordering

tests/admin_ordering/tests.py:62–73  ·  view source on GitHub ↗

Let's use a custom ModelAdmin that changes the ordering, and make sure it actually changes.

(self)

Source from the content-addressed store, hash-verified

60 self.assertEqual(["Aerosmith", "Radiohead", "Van Halen"], names)
61
62 def test_specified_ordering(self):
63 """
64 Let's use a custom ModelAdmin that changes the ordering, and make sure
65 it actually changes.
66 """
67
68 class BandAdmin(ModelAdmin):
69 ordering = ("rank",) # default ordering is ('name',)
70
71 ma = BandAdmin(Band, site)
72 names = [b.name for b in ma.get_queryset(request)]
73 self.assertEqual(["Radiohead", "Van Halen", "Aerosmith"], names)
74
75 def test_specified_ordering_by_f_expression(self):
76 class BandAdmin(ModelAdmin):

Callers

nothing calls this directly

Calls 2

BandAdminClass · 0.70
get_querysetMethod · 0.45

Tested by

no test coverage detected