add docs
This commit is contained in:
@ -15,7 +15,7 @@ multiple different models in one join.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: randomly generated alias
|
||||
`str`: randomly generated alias
|
||||
|
||||
<a name="relations.alias_manager.AliasManager"></a>
|
||||
## AliasManager Objects
|
||||
@ -27,6 +27,20 @@ class AliasManager()
|
||||
Keep all aliases of relations between different tables.
|
||||
One global instance is shared between all models.
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.reversed_aliases"></a>
|
||||
#### reversed\_aliases
|
||||
|
||||
```python
|
||||
| @property
|
||||
| reversed_aliases() -> Dict
|
||||
```
|
||||
|
||||
Returns swapped key-value pairs from aliases where alias is the key.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`Dict`: dictionary of prefix to relation
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.prefixed_columns"></a>
|
||||
#### prefixed\_columns
|
||||
|
||||
@ -43,13 +57,13 @@ List has to have sqlalchemy names of columns (ormar aliases) not the ormar ones.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `alias (str)`: alias of given table
|
||||
- `table (sqlalchemy.Table)`: table from which fields should be aliased
|
||||
- `fields (Optional[List[str]])`: fields to include
|
||||
- `alias` (`str`): alias of given table
|
||||
- `table` (`sqlalchemy.Table`): table from which fields should be aliased
|
||||
- `fields` (`Optional[List[str]]`): fields to include
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(List[text])`: list of sqlalchemy text clauses with "column name as aliased name"
|
||||
`List[text]`: list of sqlalchemy text clauses with "column name as aliased name"
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.prefixed_table_name"></a>
|
||||
#### prefixed\_table\_name
|
||||
@ -63,12 +77,12 @@ Creates text clause with table name with aliased name.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `alias (str)`: alias of given table
|
||||
- `table (sqlalchemy.Table)`: table
|
||||
- `alias` (`str`): alias of given table
|
||||
- `table` (`sqlalchemy.Table`): table
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(sqlalchemy text clause)`: sqlalchemy text clause as "table_name aliased_name"
|
||||
`sqlalchemy text clause`: sqlalchemy text clause as "table_name aliased_name"
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.add_relation_type"></a>
|
||||
#### add\_relation\_type
|
||||
@ -91,13 +105,13 @@ on one model as well as from multiple different models in one join.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `source_model (source Model)`: model with relation defined
|
||||
- `relation_name (str)`: name of the relation to define
|
||||
- `reverse_name (Optional[str])`: name of related_name fo given relation for m2m relations
|
||||
- `source_model` (`source Model`): model with relation defined
|
||||
- `relation_name` (`str`): name of the relation to define
|
||||
- `reverse_name` (`Optional[str]`): name of related_name fo given relation for m2m relations
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(None)`: none
|
||||
`None`: none
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.add_alias"></a>
|
||||
#### add\_alias
|
||||
@ -110,11 +124,11 @@ Adds alias to the dictionary of aliases under given key.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `alias_key (str)`: key of relation to generate alias for
|
||||
- `alias_key` (`str`): key of relation to generate alias for
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: generated alias
|
||||
`str`: generated alias
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.resolve_relation_alias"></a>
|
||||
#### resolve\_relation\_alias
|
||||
@ -127,12 +141,12 @@ Given model and relation name returns the alias for this relation.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `from_model (source Model)`: model with relation defined
|
||||
- `relation_name (str)`: name of the relation field
|
||||
- `from_model` (`source Model`): model with relation defined
|
||||
- `relation_name` (`str`): name of the relation field
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: alias of the relation
|
||||
`str`: alias of the relation
|
||||
|
||||
<a name="relations.alias_manager.AliasManager.resolve_relation_alias_after_complex"></a>
|
||||
#### resolve\_relation\_alias\_after\_complex
|
||||
@ -147,11 +161,11 @@ field definition.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `relation_field ("ForeignKeyField")`: field with direct relation definition
|
||||
- `source_model (source Model)`: model with query starts
|
||||
- `relation_str (str)`: string with relation joins defined
|
||||
- `relation_field` (`"ForeignKeyField"`): field with direct relation definition
|
||||
- `source_model` (`source Model`): model with query starts
|
||||
- `relation_str` (`str`): string with relation joins defined
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: alias of the relation
|
||||
`str`: alias of the relation
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ Returns queryset if it's set, AttributeError otherwise.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerySet)`: QuerySet
|
||||
`QuerySet`: QuerySet
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.queryset"></a>
|
||||
#### queryset
|
||||
@ -37,7 +37,7 @@ Set's the queryset. Initialized in RelationProxy.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `value (QuerySet)`: QuerySet
|
||||
- `value` (`QuerySet`): QuerySet
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy._assign_child_to_parent"></a>
|
||||
#### \_assign\_child\_to\_parent
|
||||
@ -50,7 +50,7 @@ Registers child in parents RelationManager.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Model)`: child to register on parent side.
|
||||
- `child` (`Model`): child to register on parent side.
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy._register_related"></a>
|
||||
#### \_register\_related
|
||||
@ -63,7 +63,7 @@ Registers child/ children in parents RelationManager.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Union[Model,List[Model]])`: child or list of children models to register.
|
||||
- `child` (`Union[Model,List[Model]]`): child or list of children models to register.
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy._clean_items_on_load"></a>
|
||||
#### \_clean\_items\_on\_load
|
||||
@ -85,8 +85,8 @@ Crete a through model instance in the database for m2m relations.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: dict of additional keyword arguments for through instance
|
||||
- `child (Model)`: child model instance
|
||||
- `kwargs` (`Any`): dict of additional keyword arguments for through instance
|
||||
- `child` (`Model`): child model instance
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.update_through_instance"></a>
|
||||
#### update\_through\_instance
|
||||
@ -99,8 +99,8 @@ Updates a through model instance in the database for m2m relations.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: dict of additional keyword arguments for through instance
|
||||
- `child (Model)`: child model instance
|
||||
- `kwargs` (`Any`): dict of additional keyword arguments for through instance
|
||||
- `child` (`Model`): child model instance
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.upsert_through_instance"></a>
|
||||
#### upsert\_through\_instance
|
||||
@ -114,8 +114,8 @@ it already exists, else creates one.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: dict of additional keyword arguments for through instance
|
||||
- `child (Model)`: child model instance
|
||||
- `kwargs` (`Any`): dict of additional keyword arguments for through instance
|
||||
- `child` (`Model`): child model instance
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.delete_through_instance"></a>
|
||||
#### delete\_through\_instance
|
||||
@ -128,7 +128,7 @@ Removes through model instance from the database for m2m relations.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Model)`: child model instance
|
||||
- `child` (`Model`): child model instance
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.exists"></a>
|
||||
#### exists
|
||||
@ -144,7 +144,7 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(bool)`: result of the check
|
||||
`bool`: result of the check
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.count"></a>
|
||||
#### count
|
||||
@ -160,7 +160,7 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(int)`: number of rows
|
||||
`int`: number of rows
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.max"></a>
|
||||
#### max
|
||||
@ -174,7 +174,7 @@ Returns max value of columns for rows matching the given criteria
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Any)`: max value of column(s)
|
||||
`Any`: max value of column(s)
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.min"></a>
|
||||
#### min
|
||||
@ -188,7 +188,7 @@ Returns min value of columns for rows matching the given criteria
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Any)`: min value of column(s)
|
||||
`Any`: min value of column(s)
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.sum"></a>
|
||||
#### sum
|
||||
@ -202,7 +202,7 @@ Returns sum value of columns for rows matching the given criteria
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(int)`: sum value of columns
|
||||
`int`: sum value of columns
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.avg"></a>
|
||||
#### avg
|
||||
@ -216,7 +216,7 @@ Returns avg value of columns for rows matching the given criteria
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Union[int, float, List])`: avg value of columns
|
||||
`Union[int, float, List]`: avg value of columns
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.clear"></a>
|
||||
#### clear
|
||||
@ -235,12 +235,12 @@ will be deleted, and not only removed from relation).
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `keep_reversed (bool)`: flag if reverse models in reverse FK should be deleted
|
||||
or not, keep_reversed=False deletes them from database.
|
||||
- `keep_reversed` (`bool`): flag if reverse models in reverse FK should be deleted
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(int)`: number of deleted models
|
||||
`int`: number of deleted models
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.first"></a>
|
||||
#### first
|
||||
@ -253,15 +253,18 @@ Gets the first row from the db ordered by primary key column ascending.
|
||||
|
||||
Actual call delegated to QuerySet.
|
||||
|
||||
Passing args and/or kwargs is a shortcut and equals to calling
|
||||
`filter(*args, **kwargs).first()`.
|
||||
|
||||
List of related models is cleared before the call.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs ()`:
|
||||
- `kwargs`:
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(_asyncio.Future)`:
|
||||
`_asyncio.Future`:
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.get_or_none"></a>
|
||||
#### get\_or\_none
|
||||
@ -274,17 +277,18 @@ Get's the first row from the db meeting the criteria set by kwargs.
|
||||
|
||||
If no criteria set it will return the last row in db sorted by pk.
|
||||
|
||||
Passing a criteria is actually calling filter(**kwargs) method described below.
|
||||
Passing args and/or kwargs is a shortcut and equals to calling
|
||||
`filter(*args, **kwargs).get_or_none()`.
|
||||
|
||||
If not match is found None will be returned.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: returned model
|
||||
`Model`: returned model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.get"></a>
|
||||
#### get
|
||||
@ -297,7 +301,8 @@ Get's the first row from the db meeting the criteria set by kwargs.
|
||||
|
||||
If no criteria set it will return the last row in db sorted by pk.
|
||||
|
||||
Passing a criteria is actually calling filter(**kwargs) method described below.
|
||||
Passing args and/or kwargs is a shortcut and equals to calling
|
||||
`filter(*args, **kwargs).get()`.
|
||||
|
||||
Actual call delegated to QuerySet.
|
||||
|
||||
@ -310,22 +315,23 @@ List of related models is cleared before the call.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: returned model
|
||||
`Model`: returned model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.all"></a>
|
||||
#### all
|
||||
|
||||
```python
|
||||
| async all(*args: Any, **kwargs: Any) -> List[Optional["T"]]
|
||||
| async all(*args: Any, **kwargs: Any) -> List["T"]
|
||||
```
|
||||
|
||||
Returns all rows from a database for given model for set filter options.
|
||||
|
||||
Passing kwargs is a shortcut and equals to calling `filter(**kwrags).all()`.
|
||||
Passing args and/or kwargs is a shortcut and equals to calling
|
||||
`filter(*args, **kwargs).all()`.
|
||||
|
||||
If there are no rows meeting the criteria an empty list is returned.
|
||||
|
||||
@ -335,11 +341,11 @@ List of related models is cleared before the call.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(List[Model])`: list of returned models
|
||||
`List[Model]`: list of returned models
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.create"></a>
|
||||
#### create
|
||||
@ -359,11 +365,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: created model
|
||||
`Model`: created model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.update"></a>
|
||||
#### update
|
||||
@ -379,12 +385,12 @@ each=True flag to affect whole table.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `each (bool)`: flag if whole table should be affected if no filter is passed
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `each` (`bool`): flag if whole table should be affected if no filter is passed
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(int)`: number of updated rows
|
||||
`int`: number of updated rows
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.get_or_create"></a>
|
||||
#### get\_or\_create
|
||||
@ -401,11 +407,11 @@ it creates a new one with given kwargs.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: returned or created Model
|
||||
`Model`: returned or created Model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.update_or_create"></a>
|
||||
#### update\_or\_create
|
||||
@ -420,11 +426,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: updated or created model
|
||||
`Model`: updated or created model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.filter"></a>
|
||||
#### filter
|
||||
@ -458,11 +464,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: filtered QuerysetProxy
|
||||
`QuerysetProxy`: filtered QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.exclude"></a>
|
||||
#### exclude
|
||||
@ -487,11 +493,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: fields names and proper value types
|
||||
- `kwargs` (`Any`): fields names and proper value types
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: filtered QuerysetProxy
|
||||
`QuerysetProxy`: filtered QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.select_all"></a>
|
||||
#### select\_all
|
||||
@ -514,13 +520,13 @@ Nested relations of those kind need to be loaded manually.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `follow (bool)`: flag to trigger deep save -
|
||||
by default only directly related models are saved
|
||||
with follow=True also related models of related models are saved
|
||||
- `follow` (`bool`): flag to trigger deep save -
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Model)`: reloaded Model
|
||||
`Model`: reloaded Model
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.select_related"></a>
|
||||
#### select\_related
|
||||
@ -543,11 +549,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `related (Union[List, str])`: list of relation field names, can be linked by '__' to nest
|
||||
- `related` (`Union[List, str]`): list of relation field names, can be linked by '__' to nest
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.prefetch_related"></a>
|
||||
#### prefetch\_related
|
||||
@ -571,11 +577,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `related (Union[List, str])`: list of relation field names, can be linked by '__' to nest
|
||||
- `related` (`Union[List, str]`): list of relation field names, can be linked by '__' to nest
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.paginate"></a>
|
||||
#### paginate
|
||||
@ -591,12 +597,12 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `page_size (int)`: numbers of items per page
|
||||
- `page (int)`: page number
|
||||
- `page_size` (`int`): numbers of items per page
|
||||
- `page` (`int`): page number
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerySet)`: QuerySet
|
||||
`QuerySet`: QuerySet
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.limit"></a>
|
||||
#### limit
|
||||
@ -611,11 +617,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `limit_count (int)`: number of models to limit
|
||||
- `limit_count` (`int`): number of models to limit
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.offset"></a>
|
||||
#### offset
|
||||
@ -630,11 +636,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `offset (int)`: numbers of models to offset
|
||||
- `offset` (`int`): numbers of models to offset
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.fields"></a>
|
||||
#### fields
|
||||
@ -683,11 +689,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `columns (Union[List, str, Set, Dict])`: columns to include
|
||||
- `columns` (`Union[List, str, Set, Dict]`): columns to include
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.exclude_fields"></a>
|
||||
#### exclude\_fields
|
||||
@ -720,11 +726,11 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `columns (Union[List, str, Set, Dict])`: columns to exclude
|
||||
- `columns` (`Union[List, str, Set, Dict]`): columns to exclude
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
<a name="relations.querysetproxy.QuerysetProxy.order_by"></a>
|
||||
#### order\_by
|
||||
@ -762,9 +768,9 @@ Actual call delegated to QuerySet.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `columns (Union[List, str])`: columns by which models should be sorted
|
||||
- `columns` (`Union[List, str]`): columns by which models should be sorted
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerysetProxy)`: QuerysetProxy
|
||||
`QuerysetProxy`: QuerysetProxy
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@ Checks if relation with given name is already registered.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `item (str)`: name of attribute
|
||||
- `item` (`str`): name of attribute
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(bool)`: result of the check
|
||||
`bool`: result of the check
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager.get"></a>
|
||||
#### get
|
||||
@ -39,11 +39,11 @@ Actual call is delegated to Relation instance registered under relation name.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `name (str)`: name of the relation
|
||||
- `name` (`str`): name of the relation
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Optional[Union[Model, List[Model]])`: related model or list of related models if set
|
||||
`Optional[Union[Model, List[Model]]`: related model or list of related models if set
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager.add"></a>
|
||||
#### add
|
||||
@ -62,9 +62,9 @@ on both ends.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `parent (Model)`: parent model on which relation should be registered
|
||||
- `child (Model)`: child model to register
|
||||
- `field (ForeignKeyField)`: field with relation definition
|
||||
- `parent` (`Model`): parent model on which relation should be registered
|
||||
- `child` (`Model`): child model to register
|
||||
- `field` (`ForeignKeyField`): field with relation definition
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager.remove"></a>
|
||||
#### remove
|
||||
@ -79,8 +79,8 @@ of relation from which you want to remove the child.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `name (str)`: name of the relation
|
||||
- `child (Union[Model, Type[Model]])`: child to remove from relation
|
||||
- `name` (`str`): name of the relation
|
||||
- `child` (`Union[Model, Type[Model]]`): child to remove from relation
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager.remove_parent"></a>
|
||||
#### remove\_parent
|
||||
@ -96,9 +96,9 @@ of relation from which you want to remove the parent.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `item (Union[Model, Type[Model]])`: model with parent registered
|
||||
- `parent (Model)`: parent Model
|
||||
- `name (str)`: name of the relation
|
||||
- `item` (`Union[Model, Type[Model]]`): model with parent registered
|
||||
- `parent` (`Model`): parent Model
|
||||
- `name` (`str`): name of the relation
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager._get"></a>
|
||||
#### \_get
|
||||
@ -111,11 +111,11 @@ Returns the actual relation and not the related model(s).
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `name (str)`: name of the relation
|
||||
- `name` (`str`): name of the relation
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(ormar.relations.relation.Relation)`: Relation instance
|
||||
`ormar.relations.relation.Relation`: Relation instance
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager._get_relation_type"></a>
|
||||
#### \_get\_relation\_type
|
||||
@ -128,11 +128,11 @@ Returns type of the relation declared on a field.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `field (BaseField)`: field with relation declaration
|
||||
- `field` (`BaseField`): field with relation declaration
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(RelationType)`: type of the relation defined on field
|
||||
`RelationType`: type of the relation defined on field
|
||||
|
||||
<a name="relations.relation_manager.RelationsManager._add_relation"></a>
|
||||
#### \_add\_relation
|
||||
@ -146,5 +146,5 @@ Adds Relation instance under field.name.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `field (BaseField)`: field with relation declaration
|
||||
- `field` (`BaseField`): field with relation declaration
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ _related_field_name property.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(str)`: name of the related field
|
||||
`str`: name of the related field
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy.__getattribute__"></a>
|
||||
#### \_\_getattribute\_\_
|
||||
@ -37,11 +37,11 @@ catch calls to them and delegate it to QuerySetProxy instead.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `item (str)`: name of attribute
|
||||
- `item` (`str`): name of attribute
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Any)`: value of attribute
|
||||
`Any`: value of attribute
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy.__getattr__"></a>
|
||||
#### \_\_getattr\_\_
|
||||
@ -54,11 +54,11 @@ Delegates calls for non existing attributes to QuerySetProxy.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `item (str)`: name of attribute/method
|
||||
- `item` (`str`): name of attribute/method
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(method)`: method from QuerySetProxy if exists
|
||||
`method`: method from QuerySetProxy if exists
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy._initialize_queryset"></a>
|
||||
#### \_initialize\_queryset
|
||||
@ -80,7 +80,7 @@ Checks if the QuerySetProxy is already set and ready.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(bool)`: result of the check
|
||||
`bool`: result of the check
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy._check_if_model_saved"></a>
|
||||
#### \_check\_if\_model\_saved
|
||||
@ -105,7 +105,7 @@ to the parent model only, without need for user to filter them.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(QuerySet)`: initialized QuerySet
|
||||
`QuerySet`: initialized QuerySet
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy.remove"></a>
|
||||
#### remove
|
||||
@ -124,8 +124,8 @@ will be deleted, and not only removed from relation).
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `item (Model)`: child to remove from relation
|
||||
- `keep_reversed (bool)`: flag if the reversed model should be kept or deleted too
|
||||
- `item` (`Model`): child to remove from relation
|
||||
- `keep_reversed` (`bool`): flag if the reversed model should be kept or deleted too
|
||||
|
||||
<a name="relations.relation_proxy.RelationProxy.add"></a>
|
||||
#### add
|
||||
@ -140,6 +140,6 @@ For ManyToMany relations through instance is automatically created.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `kwargs (Any)`: dict of additional keyword arguments for through instance
|
||||
- `item (Model)`: child to add to relation
|
||||
- `kwargs` (`Any`): dict of additional keyword arguments for through instance
|
||||
- `item` (`Model`): child to add to relation
|
||||
|
||||
|
||||
@ -37,11 +37,11 @@ related models already pre filtered by parent model.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `manager (RelationsManager)`: reference to relation manager
|
||||
- `type_ (RelationType)`: type of the relation
|
||||
- `field_name (str)`: name of the relation field
|
||||
- `to (Type[Model])`: model to which relation leads to
|
||||
- `through (Type[Model])`: model through which relation goes for m2m relations
|
||||
- `manager` (`RelationsManager`): reference to relation manager
|
||||
- `type_` (`RelationType`): type of the relation
|
||||
- `field_name` (`str`): name of the relation field
|
||||
- `to` (`Type[Model]`): model to which relation leads to
|
||||
- `through` (`Type[Model]`): model through which relation goes for m2m relations
|
||||
|
||||
<a name="relations.relation.Relation._clean_related"></a>
|
||||
#### \_clean\_related
|
||||
@ -63,11 +63,11 @@ Find child model in RelationProxy if exists.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Model)`: child model to find
|
||||
- `child` (`Model`): child model to find
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Optional[ind])`: index of child in RelationProxy
|
||||
`Optional[ind]`: index of child in RelationProxy
|
||||
|
||||
<a name="relations.relation.Relation.add"></a>
|
||||
#### add
|
||||
@ -81,7 +81,7 @@ it to the list in RelationProxy depending on relation type.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Model)`: model to add to relation
|
||||
- `child` (`Model`): model to add to relation
|
||||
|
||||
<a name="relations.relation.Relation.remove"></a>
|
||||
#### remove
|
||||
@ -95,7 +95,7 @@ it from the list in RelationProxy depending on relation type.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `child (Model)`: model to remove from relation
|
||||
- `child` (`Model`): model to remove from relation
|
||||
|
||||
<a name="relations.relation.Relation.get"></a>
|
||||
#### get
|
||||
@ -108,5 +108,5 @@ Return the related model or models from RelationProxy.
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Optional[Union[List[Model], Model]])`: related model/models if set
|
||||
`Optional[Union[List[Model], Model]]`: related model/models if set
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ changes one of the sides of the relation into weakref.proxy to model.
|
||||
|
||||
**Arguments**:
|
||||
|
||||
- `to_field (ForeignKeyField)`: field with relation definition
|
||||
- `parent (Model)`: parent model
|
||||
- `child (Model)`: child model
|
||||
- `to_field` (`ForeignKeyField`): field with relation definition
|
||||
- `parent` (`Model`): parent model
|
||||
- `child` (`Model`): child model
|
||||
|
||||
**Returns**:
|
||||
|
||||
`(Tuple["Model", "Model", str, str])`: parent, child, child_name, to_name
|
||||
`Tuple["Model", "Model", str, str]`: parent, child, child_name, to_name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user