mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing.
This commit is contained in:
parent
84fb50df67
commit
eee34ef64c
5 changed files with 26 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue