Created
March 22, 2020 06:29
-
-
Save ychennay/1c5404c1f55ff9d97a900f21d5a0c5c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuerySet: | |
"""Represent a lazy database lookup for a set of objects.""" | |
# ... | |
@property | |
def ordered(self): | |
""" | |
Return True if the QuerySet is ordered -- i.e. has an order_by() | |
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: | |
return True | |
else: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment