Manager

Usage

Source

Manager()

Methods

Name Description
__contains__() Return whether primary key is present using exists.
__delitem__() Delete row with primary key.
__getitem__() Return [QuerySet][model_values.QuerySet] which matches primary key.
bulk_change() Update changed rows with a minimal number of queries, by inverting the data to use pk__in.
bulk_changed() Return mapping of values which differ in the db.
upsert() Update or insert returning number of rows or created object.

__contains__()

Return whether primary key is present using exists.

Usage

Source

__contains__(pk)

__delitem__()

Delete row with primary key.

Usage

Source

__delitem__(pk)

__getitem__()

Return [QuerySet][model_values.QuerySet] which matches primary key.

Usage

Source

__getitem__(pk)

To encourage direct db access, instead of always using get and save.


bulk_change()

Update changed rows with a minimal number of queries, by inverting the data to use pk__in.

Usage

Source

bulk_change(field, data, key="pk", conditional=False, **kwargs)
Parameters
field

value column

data: Mapping

{pk: value, ...}

key: str = "pk"

unique key column

conditional=False

execute select query and single conditional update; may be more efficient if the percentage of changed rows is relatively small

**kwargs
additional fields to be updated

bulk_changed()

Return mapping of values which differ in the db.

Usage

Source

bulk_changed(field, data, key="pk")
Parameters
field

value column

data: Mapping

{pk: value, ...}

key: str = "pk"
unique key column

upsert()

Update or insert returning number of rows or created object.

Usage

Source

upsert(defaults={}, **kwargs)

Faster and safer than update_or_create. Supports combined expression updates by assuming the identity element on insert: F(...) + 1.

Parameters
defaults: Mapping = {}
optional mapping which will be updated, as with update_or_create.