1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing.

This commit is contained in:
Matthias Erll
2014-05-17 14:59:57 +02:00
committed by Tim Graham
parent 84fb50df67
commit eee34ef64c
5 changed files with 26 additions and 1 deletions

View File

@@ -203,6 +203,14 @@ class OrderingTests(TestCase):
attrgetter("headline")
)
def test_no_reordering_after_slicing(self):
msg = 'Cannot reverse a query once a slice has been taken.'
qs = Article.objects.all()[0:2]
with self.assertRaisesMessage(TypeError, msg):
qs.reverse()
with self.assertRaisesMessage(TypeError, msg):
qs.last()
def test_extra_ordering(self):
"""
Ordering can be based on fields included from an 'extra' clause