## F


Create [F](F.md#model_values.F), `Q`, and `Func` objects with expressions.


Usage

``` python
F()
```


> **Note: Note**
>
> Since attributes are used for constructing [F](F.md#model_values.F) objects, there may be collisions between field names and methods. For example, `name` is a reserved attribute. In such cases, use: `F("name")` or `F.user.attr("name")`.

> **Note: Note**
>
> See source for available spatial functions if `django.contrib.gis` is configured.

[F](F.md#model_values.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](https://docs.djangoproject.com/en/stable/ref/models/database-functions/#length): `F.text.length()` == `Length(F("text"))`, `F.text.length > 0` == `Q(text__length__gt=0)`.


## Classes

| Name | Description |
|----|----|
| [distance](#distance) | Return `Distance` with support for lookups: \<, \<=, \>, \>=, within. |

------------------------------------------------------------------------


#### distance


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


Usage

``` python
distance()
```


## Methods

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

------------------------------------------------------------------------


#### \_\_eq\_\_()


Return `Q` object with lookup.


Usage

``` python
__eq__(value, lookup="")
```


------------------------------------------------------------------------


#### \_\_getattr\_\_()


Return new [F](F.md#model_values.F) object with chained attribute.


Usage

``` python
__getattr__(name)
```


------------------------------------------------------------------------


#### \_\_getitem\_\_()


Return field `Substr` or `Right`.


Usage

``` python
__getitem__(slc)
```


------------------------------------------------------------------------


#### \_\_ne\_\_()


Allow \_\_ne=None lookup without custom queryset.


Usage

``` python
__ne__(value)
```


------------------------------------------------------------------------


#### count()


Return `Count` with optional field.


Usage

``` python
count(**extra)
```


------------------------------------------------------------------------


#### find()


Return `StrIndex` with `str.find` semantics.


Usage

``` python
find(sub, **extra)
```


------------------------------------------------------------------------


#### ljust()


Return `LPad` with wrapped values.


Usage

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


------------------------------------------------------------------------


#### log()


Return `Log`, by default `Ln`.


Usage

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


------------------------------------------------------------------------


#### replace()


Return `Replace` with wrapped values.


Usage

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


------------------------------------------------------------------------


#### rjust()


Return `RPad` with wrapped values.


Usage

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