F

Create F, Q, and Func objects with expressions.

Usage

Source

F()
Note

Since attributes are used for constructing F objects, there may be collisions between field names and methods. For example, name is a reserved attribute, but the usual constructor can still be used: F('name').

Note

See source for available spatial functions if django.contrib.gis is configured.

F creation supported as attributes: F.user == F('user'), F.user.created == F('user__created').

Q lookups supported as methods or operators: F.text.iexact(...) == Q(text__iexact=...), F.user.created >= ... == Q(user__created__gte=...).

Func objects also supported as methods: F.user.created.min() == Min('user__created').

Some Func objects can also be transformed into lookups, if registered: F.text.length() == Length(F('text')), F.text.length > 0 == Q(text__length__gt=0).

Classes

Name Description
distance Return Distance with support for lookups: <, <=, >, >=, within.

distance

Return Distance with support for lookups: <, <=, >, >=, within.

Usage

Source

distance()

Methods

Name Description
__eq__() Return Q object with lookup.
__getattr__() Return new [F][model_values.F] object with chained attribute.
__getitem__() Return field Substr or Right.
__ne__() Allow __ne=None lookup without custom queryset.
count() Return Count with optional field.
find() Return StrIndex with str.find semantics.
ljust() Return LPad with wrapped values.
log() Return Log, by default Ln.
replace() Return Replace with wrapped values.
rjust() Return RPad with wrapped values.

__eq__()

Return Q object with lookup.

Usage

Source

__eq__(value, lookup="")

__getattr__()

Return new [F][model_values.F] object with chained attribute.

Usage

Source

__getattr__(name)

__getitem__()

Return field Substr or Right.

Usage

Source

__getitem__(slc)

__ne__()

Allow __ne=None lookup without custom queryset.

Usage

Source

__ne__(value)

count()

Return Count with optional field.

Usage

Source

count(**extra)

find()

Return StrIndex with str.find semantics.

Usage

Source

find(sub, **extra)

ljust()

Return LPad with wrapped values.

Usage

Source

ljust(width, fill=" ", **extra)

log()

Return Log, by default Ln.

Usage

Source

log(base=math.e, **extra)

replace()

Return Replace with wrapped values.

Usage

Source

replace(old, new="", **extra)

rjust()

Return RPad with wrapped values.

Usage

Source

rjust(width, fill=" ", **extra)