finish docstrings in relations package

This commit is contained in:
collerek
2021-01-03 16:46:46 +01:00
parent 7a8d11b1c7
commit a32a3b9d59
7 changed files with 623 additions and 6 deletions

View File

@ -16,6 +16,25 @@ def get_relations_sides_and_names(
virtual: bool,
relation_name: str,
) -> Tuple["Model", "Model", str, str]:
"""
Determines the names of child and parent relations names, as well as
changes one of the sides of the relation into weakref.proxy to model.
:param to_field: field with relation definition
:type to_field: BaseField
:param parent: parent model
:type parent: Model
:param child: child model
:type child: Model
:param child_name: name of the child
:type child_name: str
:param virtual: flag if relation is virtual
:type virtual: bool
:param relation_name:
:type relation_name:
:return: parent, child, child_name, to_name
:rtype: Tuple["Model", "Model", str, str]
"""
to_name = to_field.name
if issubclass(to_field, ManyToManyField):
child_name = to_field.related_name or child.get_name() + "s"