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

@ -944,6 +944,8 @@ class QuerySet:
def reverse(self):
"""Reverse the ordering of the QuerySet."""
if not self.query.can_filter():
raise TypeError('Cannot reverse a query once a slice has been taken.')
clone = self._clone()
clone.query.standard_ordering = not clone.query.standard_ordering
return clone