Repository: django/django
File: django/db/models/query.py (Python)

Code before:
    ###################################

    @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
            and
            # A default ordering doesn't affect GROUP BY queries.
            not self.query.group_by
        ):
            return True
        else:
            return False

    @property
    def totally_ordered(self):
        """
        Return True if the QuerySet is ordered and the ordering is sufficient
        to guarantee a stable sort.
        Search for a single field or unique together set of fields providing a
        total ordering. .extra(order_by=...) is ignored by this property.
        """

        if self.query.group_by:
            return False

        if not self.ordered:
            return False

        ordering = self.query.order_by
        if not ordering and self.query.default_ordering:
            ordering = self.query.get_meta().ordering

        if not ordering:
            return False

        opts = self.model._meta
        pk_fields = {f.attname for f in opts.pk_fields}
        ordering_fields = set()

        for part in ordering:
            # Search for single field providing a total ordering.

Review comment (suggestion):
Taking inspiration from the removed function, I wonder if `has_deterministic_order` would be a better name for this property. 

Code after:
    # PUBLIC INTROSPECTION ATTRIBUTES #
    ###################################

    @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
            and
            # A default ordering doesn't affect GROUP BY queries.
            not self.query.group_by
        ):
            return True
        else:
            return False

    @property
    def totally_ordered(self):
        """
        Returns True if the QuerySet is ordered and the ordering is
        deterministic. This requires that the ordering includes a field
        (or set of fields) that is unique and non-nullable.

        For queries involving a GROUP BY clause, the model's default
        ordering is ignored. Ordering specified via .extra(order_by=...)
        is also ignored.
        """
        if not self.ordered:
            return False
        ordering = self.query.order_by
        if not ordering and self.query.default_ordering:
            ordering = self.query.get_meta().ordering
        if not ordering:
            return False
        opts = self.model._meta
        pk_fields = {f.attname for f in opts.pk_fields}
        ordering_fields = set()
        for part in ordering:
            # Search for single field providing a total ordering.
            field_name = None
            if isinstance(part, str):
                field_name = part.lstrip("-")
            elif isinstance(part, F):