summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorJosh Schneier <josh.schneier@gmail.com>2018-07-15 17:47:17 -0400
committerTim Graham <timograham@gmail.com>2018-07-16 14:28:47 -0400
commit4d48ddd8f93800a80330ec1dee7b7d4afe6ea95a (patch)
tree1c22c51ef214939f38314ead69d96fdd0309843c /django/db
parent93e721a0b8155470336357c148c4d8364c36bbee (diff)
Fixed #28917 -- Prevented Paginator's unordered warning on EmptyQuerySet.
Thanks carltongibson for the idea and weijunji for the initial patch.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/models/query.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 5ae451879c..c0d2dee3c1 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1100,8 +1100,10 @@ class QuerySet:
def ordered(self):
"""
Return True if the QuerySet is ordered -- i.e. has an order_by()
- clause or a default ordering on the model.
+ clause or a default ordering on the model (or is empty).
"""
+ if isinstance(self, EmptyQuerySet):
+ return True
if self.query.extra_order_by or self.query.order_by:
return True
elif self.query.default_ordering and self.query.get_meta().ordering: