class Expression [source]
-
contains_aggregate -
Tells Django that this expression contains an aggregate and that a
GROUP BYclause needs to be added to the query.
-
resolve_expression(query=None, allow_joins=True, reuse=None, summarize=False, for_save=False) -
Provides the chance to do any pre-processing or validation of the expression before it’s added to the query.
resolve_expression()must also be called on any nested expressions. Acopy()ofselfshould be returned with any necessary transformations.queryis the backend query implementation.allow_joinsis a boolean that allows or denies the use of joins in the query.reuseis a set of reusable joins for multi-join scenarios.summarizeis a boolean that, whenTrue, signals that the query being computed is a terminal aggregate query.
-
get_source_expressions() -
Returns an ordered list of inner expressions. For example:
>>> Sum(F('foo')).get_source_expressions() [F('foo')]
-
set_source_expressions(expressions) -
Takes a list of expressions and stores them such that
get_source_expressions()can return them.
-
relabeled_clone(change_map) -
Returns a clone (copy) of
self, with any column aliases relabeled. Column aliases are renamed when subqueries are created.relabeled_clone()should also be called on any nested expressions and assigned to the clone.change_mapis a dictionary mapping old aliases to new aliases.Example:
def relabeled_clone(self, change_map): clone = copy.copy(self) clone.expression = self.expression.relabeled_clone(change_map) return clone
-
convert_value(self, value, expression, connection, context) -
A hook allowing the expression to coerce
valueinto a more appropriate type.
-
get_group_by_cols() -
Responsible for returning the list of columns references by this expression.
get_group_by_cols()should be called on any nested expressions.F()objects, in particular, hold a reference to a column.
-
asc() -
Returns the expression ready to be sorted in ascending order.
-
desc() -
Returns the expression ready to be sorted in descending order.
-
reverse_ordering() -
Returns
selfwith any modifications required to reverse the sort order within anorder_bycall. As an example, an expression implementingNULLS LASTwould change its value to beNULLS FIRST. Modifications are only required for expressions that implement sort order likeOrderBy. This method is called whenreverse()is called on a queryset.
Please login to continue.