summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorMatthias Erll <matthias@precisdigital.com>2014-05-17 14:59:57 +0200
committerTim Graham <timograham@gmail.com>2017-05-31 19:34:56 -0400
commiteee34ef64c026e3274c6d1b4fa2baffbc956b954 (patch)
tree1ed5087f7396fafc49560e8106cf23c6d1afd99c /django/db
parent84fb50df670c8126983c9f0fd4a5c30dbe57b684 (diff)
Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/models/query.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index a20237a229..fdf720cb8a 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -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