class RawQuerySet

from django.db.models.query import RawQuerySet
Provide an iterator which converts the results of raw SQL queries into
annotated model instances.

Ancestors (MRO)

  1. builtins.object
  2. django.db.models.query.RawQuerySet
def columns(self)
django.db.models.query.RawQuerySet
A list of model field names in the order they'll appear in the
query results.
def db(self)
django.db.models.query.RawQuerySet
Return the database used if this query is executed now.
def iterator(self)
django.db.models.query.RawQuerySet
    def iterator(self):
        yield from RawModelIterable(self)
def model_fields(self)
django.db.models.query.RawQuerySet
A dict mapping column names to model field names.
def prefetch_related(self, *lookups)
django.db.models.query.RawQuerySet
Same as QuerySet.prefetch_related()
    def prefetch_related(self, *lookups):
        """Same as QuerySet.prefetch_related()"""
        clone = self._clone()
        if lookups == (None,):
            clone._prefetch_related_lookups = ()
        else:
            clone._prefetch_related_lookups = clone._prefetch_related_lookups + lookups
        return clone
def resolve_model_init_order(self)
django.db.models.query.RawQuerySet
Resolve the init field names and value positions.
    def resolve_model_init_order(self):
        """Resolve the init field names and value positions."""
        converter = connections[self.db].introspection.identifier_converter
        model_init_fields = [
            f for f in self.model._meta.fields if converter(f.column) in self.columns
        ]
        annotation_fields = [
            (column, pos)
            for pos, column in enumerate(self.columns)
            if column not in self.model_fields
        ]
        model_init_order = [
            self.columns.index(converter(f.column)) for f in model_init_fields
        ]
        model_init_names = [f.attname for f in model_init_fields]
        return model_init_names, model_init_order, annotation_fields
def using(self, alias)
django.db.models.query.RawQuerySet
Select the database this RawQuerySet should execute against.
    def using(self, alias):
        """Select the database this RawQuerySet should execute against."""
        return RawQuerySet(
            self.raw_query,
            model=self.model,
            query=self.query.chain(using=alias),
            params=self.params,
            translations=self.translations,
            using=alias,
        )