mirror of
https://github.com/django/django.git
synced 2025-10-28 16:16:12 +00:00
Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing.
This commit is contained in:
committed by
Tim Graham
parent
84fb50df67
commit
eee34ef64c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user