psqlextra/query.py
def rename_annotations(self, annotations) -> None:
        """Renames the aliases for the specified annotations:

            .annotate(myfield=F('somestuf__myfield'))
            .rename_annotations(myfield='field')

        Arguments:
            annotations:
                The annotations to rename. Mapping the
                old name to the new name.
        """

        for old_name, new_name in annotations.items():
            annotation = self.annotations.get(old_name)

            if not annotation:
                raise SuspiciousOperation((
                    'Cannot rename annotation "{old_name}" to "{new_name}", because there'
                    ' is no annotation named "{old_name}".'
                ).format(old_name=old_name, new_name=new_name))

            self._annotations = OrderedDict(
                [(new_name, v) if k == old_name else (k, v) for k, v in self._annotations.items()])

            if django.VERSION < (2, 0):
                self.set_annotation_mask(
                    (new_name if v == old_name else v for v in (self.annotation_select_mask or [])))
def rename_annotations(self, annotations) -> None:
        """Renames the aliases for the specified annotations:

            .annotate(myfield=F('somestuf__myfield'))
            .rename_annotations(myfield='field')

        Arguments:
            annotations:
                The annotations to rename. Mapping the
                old name to the new name.
        """

        for old_name, new_name in annotations.items():
            annotation = self.annotations.get(old_name)

            if not annotation:
                raise SuspiciousOperation((
                    'Cannot rename annotation "{old_name}" to "{new_name}", because there'
                    ' is no annotation named "{old_name}".'
                ).format(old_name=old_name, new_name=new_name))

            self._annotations = OrderedDict(
                [(new_name, v) if k == old_name else (k, v) for k, v in self._annotations.items()])

            if django.VERSION < (2, 0):
                self.set_annotation_mask(
                    (new_name if v == old_name else v for v in (self.annotation_select_mask or [])))
Renames the aliases for the specified annotations:

            .annotate(myfield=F('somestuf__myfield'))
            .rename_annotations(myfield='field')

        Arguments:
            annotations:
                The annotations to rename. Mapping the
                old name to the new name.