class documentation

class Query(BaseExpression):

Known subclasses: django.db.models.sql.subqueries.AggregateQuery, django.db.models.sql.subqueries.DeleteQuery, django.db.models.sql.subqueries.InsertQuery, django.db.models.sql.subqueries.UpdateQuery

View In Hierarchy

A single SQL query.
Class Method ​_gen​_col​_aliases Undocumented
Class Method ​_gen​_cols Undocumented
Method __deepcopy__ Limit the amount of work when a Query is deepcopied.
Method __init__ Undocumented
Method __str__ Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string).
Method ​_add​_q Add a Q-object to the current filter.
Method ​_get​_col Undocumented
Method add​_annotation Add a single annotation expression to the Query.
Method add​_deferred​_loading No summary
Method add​_distinct​_fields Add and resolve the given fields to the query's "distinct on" clause.
Method add​_extra Add data to the various extra_* attributes for user-created additions to the query.
Method add​_fields Add the given (model) fields to the select set. Add the field names in the order specified.
Method add​_filter Undocumented
Method add​_filtered​_relation Undocumented
Method add​_immediate​_loading No summary
Method add​_ordering No summary
Method add​_q A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
Method add​_select​_col Undocumented
Method add​_select​_related Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
Method append​_annotation​_mask Undocumented
Method as​_sql Responsible for returning a (sql, [params]) tuple to be included in the current query.
Method build​_filter Build a WhereNode for a single filter clause but don't add it to this Query. Query.add_q() will then add this filter to the where Node.
Method build​_filtered​_relation​_q Add a FilteredRelation object to the current filter.
Method build​_lookup Try to extract transforms and lookup from given lhs.
Method build​_where Undocumented
Method bump​_prefix No summary
Method can​_filter Return True if adding filters to this instance is still possible.
Method chain Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery.
Method change​_aliases Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
Method check​_filterable Raise an error if expression cannot be used in a WHERE clause.
Method check​_query​_object​_type Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object.
Method check​_related​_objects Check the type of object passed to query relations.
Method clear​_deferred​_loading Remove any fields from the deferred loading set.
Method clear​_limits Clear any existing limits.
Method clear​_ordering No summary
Method clear​_select​_clause Remove all fields from SELECT clause.
Method clear​_select​_fields Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
Method clear​_where Undocumented
Method clone Return a copy of the current Query. A lightweight alternative to to deepcopy().
Method combine Merge the 'rhs' query into the current one (with any 'rhs' effects being applied after (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function.
Method count​_active​_tables Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
Method deferred​_to​_data No summary
Method demote​_joins Change join type from LOUTER to INNER for all joins in aliases.
Method exists Undocumented
Method explain Undocumented
Method get​_aggregation Return the dictionary with the values of the existing aggregations.
Method get​_compiler Undocumented
Method get​_count Perform a COUNT() query using the current filter constraints.
Method get​_external​_cols Undocumented
Method get​_initial​_alias Return the first alias for this query, after increasing its reference count.
Method get​_loaded​_field​_names No summary
Method get​_loaded​_field​_names​_cb Callback used by get_deferred_field_names().
Method get​_meta Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
Method has​_filters Undocumented
Method has​_limit​_one Undocumented
Method has​_results Undocumented
Method is​_empty Undocumented
Method is​_nullable Check if the given field should be treated as nullable.
Method join Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join.
Method join​_parent​_model Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op.
Method names​_to​_path Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example).
Method promote​_joins Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join.
Method ref​_alias Increases the reference count for this alias.
Method relabeled​_clone Undocumented
Method reset​_refcounts Reset reference counts for aliases so that they match the value passed in to_counts.
Method resolve​_expression Provide the chance to do any preprocessing or validation before being added to the query.
Method resolve​_lookup​_value Undocumented
Method resolve​_ref Undocumented
Method rewrite​_cols Undocumented
Method set​_annotation​_mask Set the mask of annotations that will be returned by the SELECT.
Method set​_empty Undocumented
Method set​_extra​_mask Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later.
Method set​_group​_by Expand the GROUP BY clause required by the query.
Method set​_limits Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values.
Method set​_select Undocumented
Method set​_values Undocumented
Method setup​_joins No summary
Method solve​_lookup​_type Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
Method split​_exclude No summary
Method sql​_with​_params Return the query as an SQL string and the parameters that will be substituted into the query.
Method table​_alias Return a table alias for the given table_name and whether this is a new alias or not.
Method trim​_joins The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins.
Method trim​_start Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins.
Method try​_transform Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs.
Method unref​_alias Decreases the reference count for this alias.
Class Variable compiler Undocumented
Class Variable empty​_result​_set​_value Undocumented
Instance Variable ​_annotation​_select​_cache Undocumented
Instance Variable ​_extra​_select​_cache Undocumented
Instance Variable ​_filtered​_relations Undocumented
Instance Variable ​_loaded​_field​_names​_cache Undocumented
Instance Variable ​_lookup​_joins Undocumented
Instance Variable alias​_cols Undocumented
Instance Variable alias​_map Undocumented
Instance Variable alias​_prefix Undocumented
Instance Variable alias​_refcount Undocumented
Instance Variable annotation​_select​_mask Undocumented
Instance Variable annotations Undocumented
Instance Variable combinator Undocumented
Instance Variable combinator​_all Undocumented
Instance Variable combined​_queries Undocumented
Instance Variable default​_cols Undocumented
Instance Variable default​_ordering Undocumented
Instance Variable deferred​_loading Undocumented
Instance Variable distinct Undocumented
Instance Variable distinct​_fields Undocumented
Instance Variable explain​_info Undocumented
Instance Variable external​_aliases Undocumented
Instance Variable extra Undocumented
Instance Variable extra​_order​_by Undocumented
Instance Variable extra​_select​_mask Undocumented
Instance Variable extra​_tables Undocumented
Instance Variable filter​_is​_sticky Undocumented
Instance Variable group​_by Undocumented
Instance Variable high​_mark Undocumented
Instance Variable low​_mark Undocumented
Instance Variable max​_depth Undocumented
Instance Variable model Undocumented
Instance Variable order​_by Undocumented
Instance Variable select Undocumented
Instance Variable select​_for​_no​_key​_update Undocumented
Instance Variable select​_for​_update Undocumented
Instance Variable select​_for​_update​_nowait Undocumented
Instance Variable select​_for​_update​_of Undocumented
Instance Variable select​_for​_update​_skip​_locked Undocumented
Instance Variable select​_related Undocumented
Instance Variable standard​_ordering Undocumented
Instance Variable subq​_aliases Undocumented
Instance Variable subquery Undocumented
Instance Variable table​_map Undocumented
Instance Variable used​_aliases Undocumented
Instance Variable values​_select Undocumented
Instance Variable where Undocumented
Property annotation​_select Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance.
Property base​_table Undocumented
Property extra​_select Undocumented
Property has​_select​_fields Undocumented
Property is​_sliced Undocumented
Property output​_field Return the output type of this expressions.

Inherited from BaseExpression:

Static Method ​_convert​_value​_noop Undocumented
Method __getstate__ Undocumented
Method ​_parse​_expressions Undocumented
Method ​_resolve​_output​_field Attempt to infer the output type of the expression. If the output fields of all source fields match then, simply infer the same type here. This isn't always correct, but it makes sense most of the time.
Method asc Undocumented
Method copy Undocumented
Method desc Undocumented
Method flatten Recursively yield this expression and all subexpressions, in depth-first order.
Method get​_db​_converters Undocumented
Method get​_group​_by​_cols Undocumented
Method get​_lookup Undocumented
Method get​_source​_expressions Undocumented
Method get​_source​_fields Return the underlying field types used by this aggregate.
Method get​_transform Undocumented
Method reverse​_ordering Undocumented
Method select​_format Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle.
Method set​_source​_expressions Undocumented
Class Variable ​_output​_field​_resolved​_to​_none Undocumented
Class Variable filterable Undocumented
Class Variable is​_summary Undocumented
Class Variable window​_compatible Undocumented
Property ​_output​_field​_or​_none Return the output field of this expression, or None if _resolve_output_field() didn't return an output type.
Property conditional Undocumented
Property contains​_aggregate Undocumented
Property contains​_column​_references Undocumented
Property contains​_over​_clause Undocumented
Property convert​_value Expressions provide their own converters because users have the option of manually specifying the output_field which may be a different type from the one the database returns.
Property field Undocumented
@classmethod
def _gen_col_aliases(cls, exprs):

Undocumented

@classmethod
def _gen_cols(cls, exprs, include_external=False):

Undocumented

def __deepcopy__(self, memo):
Limit the amount of work when a Query is deepcopied.
def __str__(self):

Return the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string).

Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time.

def _add_q(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True, check_filterable=True):
Add a Q-object to the current filter.
def _get_col(self, target, field, alias):

Undocumented

def add_annotation(self, annotation, alias, is_summary=False, select=True):
Add a single annotation expression to the Query.
def add_deferred_loading(self, field_names):
Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. Add the new field names to any existing field names that are deferred (or removed from any existing field names that are marked as the only ones for immediate loading).
def add_distinct_fields(self, *field_names):
Add and resolve the given fields to the query's "distinct on" clause.
def add_extra(self, select, select_params, where, params, tables, order_by):
Add data to the various extra_* attributes for user-created additions to the query.
def add_fields(self, field_names, allow_m2m=True):
Add the given (model) fields to the select set. Add the field names in the order specified.
def add_filter(self, filter_lhs, filter_rhs):

Undocumented

def add_filtered_relation(self, filtered_relation, alias):

Undocumented

def add_immediate_loading(self, field_names):
Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, remove those names from the new field_names before storing the new names for immediate loading. (That is, immediate loading overrides any existing immediate values, but respects existing deferrals.)
def add_ordering(self, *ordering):

Add items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions.

If 'ordering' is empty, clear all ordering from the query.

def add_q(self, q_object):
A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
def add_select_col(self, col, name):

Undocumented

def add_select_related(self, fields):
Set up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
def append_annotation_mask(self, names):

Undocumented

def as_sql(self, compiler, connection):

Responsible for returning a (sql, [params]) tuple to be included in the current query.

Different backends can provide their own implementation, by providing an as_{vendor} method and patching the Expression:

``` def override_as_sql(self, compiler, connection):

# custom logic return super().as_sql(compiler, connection)

setattr(Expression, 'as_' + connection.vendor, override_as_sql) ```

Arguments:
  • compiler: the query compiler responsible for generating the query. Must have a compile method, returning a (sql, [params]) tuple. Calling compiler(value) will return a quoted value.
  • connection: the database connection used for the current query.
Return: (sql, params)
Where sql is a string containing ordered sql parameters to be replaced with the elements of the list params.
def build_filter(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, allow_joins=True, split_subq=True, check_filterable=True):

Build a WhereNode for a single filter clause but don't add it to this Query. Query.add_q() will then add this filter to the where Node.

The 'branch_negated' tells us if the current branch contains any negations. This will be used to determine if subqueries are needed.

The 'current_negated' is used to determine if the current filter is negated or not and this will be used to determine if IS NULL filtering is needed.

The difference between current_negated and branch_negated is that branch_negated is set on first negation, but current_negated is flipped for each negation.

Note that add_filter will not do any negating itself, that is done upper in the code by add_q().

The 'can_reuse' is a set of reusable joins for multijoins.

The method will create a filter clause that can be added to the current query. However, if the filter isn't added to the query then the caller is responsible for unreffing the joins used.

def build_filtered_relation_q(self, q_object, reuse, branch_negated=False, current_negated=False):
Add a FilteredRelation object to the current filter.
def build_lookup(self, lookups, lhs, rhs):

Try to extract transforms and lookup from given lhs.

The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_lookup() and get_transform().

def build_where(self, filter_expr):

Undocumented

def bump_prefix(self, outer_query):
Change the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call.
def can_filter(self):

Return True if adding filters to this instance is still possible.

Typically, this means no limits or offsets have been put on the results.

def chain(self, klass=None):
Return a copy of the current Query that's ready for another operation. The klass argument changes the type of the Query, e.g. UpdateQuery.
def change_aliases(self, change_map):
Change the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
def check_filterable(self, expression):
Raise an error if expression cannot be used in a WHERE clause.
def check_query_object_type(self, value, opts, field):
Check whether the object passed while querying is of the correct type. If not, raise a ValueError specifying the wrong object.
def check_related_objects(self, field, value, opts):
Check the type of object passed to query relations.
def clear_deferred_loading(self):
Remove any fields from the deferred loading set.
def clear_limits(self):
Clear any existing limits.
def clear_ordering(self, force=False, clear_default=True):
Remove any ordering settings if the current query allows it without side effects, set 'force' to True to clear the ordering regardless. If 'clear_default' is True, there will be no ordering in the resulting query (not even the model's default).
def clear_select_clause(self):
Remove all fields from SELECT clause.
def clear_select_fields(self):
Clear the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
def clear_where(self):

Undocumented

def clone(self):
Return a copy of the current Query. A lightweight alternative to to deepcopy().
def combine(self, rhs, connector):

Merge the 'rhs' query into the current one (with any 'rhs' effects being applied after (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function.

The 'connector' parameter describes how to connect filters from the 'rhs' query.

def count_active_tables(self):
Return the number of tables in this query with a non-zero reference count. After execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
def deferred_to_data(self, target, callback):

Convert the self.deferred_loading data structure to an alternate data structure, describing the field that will be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each model. Models that have all their fields included aren't mentioned in the result, only those that have field restrictions in place.

The "target" parameter is the instance that is populated (in place). The "callback" is a function that is called whenever a (model, field) pair need to be added to "target". It accepts three parameters: "target", and the model and list of fields being added for that model.

def demote_joins(self, aliases):

Change join type from LOUTER to INNER for all joins in aliases.

Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b LOUTER c then we must demote a->b automatically, or otherwise the demotion of b->c doesn't actually change anything in the query results. .

def exists(self, using, limit=True):

Undocumented

def explain(self, using, format=None, **options):

Undocumented

def get_aggregation(self, using, added_aggregate_names):
Return the dictionary with the values of the existing aggregations.
def get_compiler(self, using=None, connection=None, elide_empty=True):

Undocumented

def get_count(self, using):
Perform a COUNT() query using the current filter constraints.
def get_external_cols(self):

Undocumented

def get_initial_alias(self):
Return the first alias for this query, after increasing its reference count.
def get_loaded_field_names(self):

If any fields are marked to be deferred, return a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred.

If no fields are marked for deferral, return an empty dictionary.

def get_loaded_field_names_cb(self, target, model, fields):
Callback used by get_deferred_field_names().
def get_meta(self):
Return the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
def has_filters(self):

Undocumented

def has_limit_one(self):

Undocumented

def has_results(self, using):

Undocumented

def is_empty(self):

Undocumented

def is_nullable(self, field):

Check if the given field should be treated as nullable.

Some backends treat '' as null and Django treats such fields as nullable for those backends. In such situations field.null can be False even if we should treat the field as nullable.

def join(self, join, reuse=None):

Return an alias for the 'join', either reusing an existing alias for that join or creating a new one. 'join' is either a sql.datastructures.BaseTable or Join.

The 'reuse' parameter can be either None which means all joins are reusable, or it can be a set containing the aliases that can be reused.

A join is always created as LOUTER if the lhs alias is LOUTER to make sure chains like t1 LOUTER t2 INNER t3 aren't generated. All new joins are created as LOUTER if the join is nullable.

def join_parent_model(self, opts, model, alias, seen):

Make sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op.

The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of existing joins. It must also contain a mapping of None -> some alias. This will be returned in the no-op case.

def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False):

Walk the list of names and turns them into PathInfo tuples. A single name in 'names' can generate multiple PathInfos (m2m, for example).

'names' is the path of names to travel, 'opts' is the model Options we start the name resolving from, 'allow_many' is as for setup_joins(). If fail_on_missing is set to True, then a name that can't be resolved will generate a FieldError.

Return a list of PathInfo tuples. In addition return the final field (the last used join field) and target (which is a field guaranteed to contain the same value as the final field). Finally, return those names that weren't found (which are likely transforms and the final lookup).

def promote_joins(self, aliases):

Promote recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, only promote the join if it is nullable or the parent join is an outer join.

The children promotion is done to avoid join chains that contain a LOUTER b INNER c. So, if we have currently a INNER b INNER c and a->b is promoted, then we must also promote b->c automatically, or otherwise the promotion of a->b doesn't actually change anything in the query results.

def ref_alias(self, alias):
Increases the reference count for this alias.
def relabeled_clone(self, change_map):
def reset_refcounts(self, to_counts):
Reset reference counts for aliases so that they match the value passed in to_counts.
def resolve_expression(self, query, *args, **kwargs):

Provide the chance to do any preprocessing or validation before being added to the query.

Arguments:
  • query: the backend query implementation
  • allow_joins: boolean allowing or denying use of joins in this query
  • reuse: a set of reusable joins for multijoins
  • summarize: a terminal aggregate clause
  • for_save: whether this expression about to be used in a save or update

Return: an Expression to be added to the query.

def resolve_lookup_value(self, value, can_reuse, allow_joins):

Undocumented

def resolve_ref(self, name, allow_joins=True, reuse=None, summarize=False):

Undocumented

def rewrite_cols(self, annotation, col_cnt):

Undocumented

def set_annotation_mask(self, names):
Set the mask of annotations that will be returned by the SELECT.
def set_empty(self):

Undocumented

def set_extra_mask(self, names):
Set the mask of extra select items that will be returned by SELECT. Don't remove them from the Query since they might be used later.
def set_group_by(self, allow_aliases=True):

Expand the GROUP BY clause required by the query.

This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the optimization will be made automatically.

def set_limits(self, low=None, high=None):

Adjust the limits on the rows retrieved. Use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, convert them to the appropriate offset and limit values.

Apply any limits passed in here to the existing constraints. Add low to the current low value and clamp both to any existing high value.

def set_select(self, cols):

Undocumented

def set_values(self, fields):

Undocumented

def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True):

Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from.

The 'can_reuse' defines the reverse foreign key joins we can reuse. It can be None in which case all joins are reusable or a set of aliases that can be reused. Note that non-reverse foreign keys are always reusable when using setup_joins().

If 'allow_many' is False, then any reverse foreign key seen will generate a MultiJoin exception.

Return the final field involved in the joins, the target field (used for any 'where' constraint), the final 'opts' value, the joins, the field path traveled to generate the joins, and a transform function that takes a field and alias and is equivalent to field.get_col(alias) in the simple case but wraps field transforms if they were included in names.

The target field is the field containing the concrete value. Final field can be something different, for example foreign key pointing to that value. Final field is needed for example in some value conversions (convert 'obj' in fk__id=obj to pk val using the foreign key field for example).

def solve_lookup_type(self, lookup):
Solve the lookup type from the lookup (e.g.: 'foobar__id__icontains').
def split_exclude(self, filter_expr, can_reuse, names_with_path):

When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field.

For example, if the origin filter is ~Q(child__name='foo'), filter_expr is ('child__name', 'foo') and can_reuse is a set of joins usable for filters in the original query.

We will turn this into equivalent of:
WHERE NOT EXISTS(
SELECT 1 FROM child WHERE name = 'foo' AND child.parent_id = parent.id LIMIT 1

)

def sql_with_params(self):
Return the query as an SQL string and the parameters that will be substituted into the query.
def table_alias(self, table_name, create=False, filtered_relation=None):

Return a table alias for the given table_name and whether this is a new alias or not.

If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused.

def trim_joins(self, targets, joins, path):

The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins.

Return the final target field and table alias and the new active joins.

Always trim any direct join if the target column is already in the previous table. Can't trim reverse joins as it's unknown if there's anything on the other side of the join.

def trim_start(self, names_with_path):

Trim joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins.

Also set the select column so the start matches the join.

This method is meant to be used for generating the subquery joins & cols in split_exclude().

Return a lookup usable for doing outerq.filter(lookup=self) and a boolean indicating if the joins in the prefix contain a LEFT OUTER join. _

def try_transform(self, lhs, name):
Helper method for build_lookup(). Try to fetch and initialize a transform for name parameter from lhs.
def unref_alias(self, alias, amount=1):
Decreases the reference count for this alias.
empty_result_set_value =

Undocumented

_annotation_select_cache =

Undocumented

_extra_select_cache =

Undocumented

_filtered_relations: dict =

Undocumented

_loaded_field_names_cache =

Undocumented

_lookup_joins =

Undocumented

alias_cols =

Undocumented

alias_map: dict =

Undocumented

alias_prefix =

Undocumented

alias_refcount: dict =

Undocumented

annotation_select_mask =

Undocumented

annotations =

Undocumented

combinator =

Undocumented

combinator_all: bool =

Undocumented

combined_queries: tuple =

Undocumented

default_cols: bool =

Undocumented

default_ordering: bool =

Undocumented

deferred_loading =

Undocumented

distinct: bool =

Undocumented

distinct_fields =

Undocumented

explain_info =

Undocumented

external_aliases =

Undocumented

extra: dict =

Undocumented

extra_order_by =

Undocumented

extra_select_mask =

Undocumented

extra_tables: tuple =

Undocumented

filter_is_sticky: bool =

Undocumented

group_by =

Undocumented

high_mark =

Undocumented

low_mark =

Undocumented

max_depth: int =

Undocumented

model =

Undocumented

order_by: tuple =

Undocumented

select =

Undocumented

select_for_no_key_update: bool =

Undocumented

select_for_update: bool =

Undocumented

select_for_update_nowait: bool =

Undocumented

select_for_update_of: tuple =

Undocumented

select_for_update_skip_locked: bool =

Undocumented

select_related: bool =

Undocumented

standard_ordering: bool =

Undocumented

subq_aliases =

Undocumented

subquery: bool =

Undocumented

table_map: dict =

Undocumented

used_aliases: set =

Undocumented

values_select =

Undocumented

where =

Undocumented

@property
annotation_select =
Return the dictionary of aggregate columns that are not masked and should be used in the SELECT clause. Cache this result for performance.
@cached_property
base_table =

Undocumented

@property
extra_select =

Undocumented

@property
has_select_fields =

Undocumented

@property
is_sliced =

Undocumented

@property
output_field =
Return the output type of this expressions.