refactor and cleanup - drop of resolving relation names as not fully proper, extract mixins from modelproxy to be more maintainable, add some docstrings

This commit is contained in:
collerek
2020-12-30 16:41:26 +01:00
parent cc23b5a879
commit e695db712f
18 changed files with 488 additions and 406 deletions

View File

@ -14,16 +14,11 @@ def get_relations_sides_and_names(
child: "Model",
child_name: str,
virtual: bool,
relation_name: str,
) -> Tuple["Model", "Model", str, str]:
to_name = to_field.name
if issubclass(to_field, ManyToManyField):
child_name, to_name = (
to_field.related_name
or child.resolve_relation_name(
parent, to_field.through, explicit_multi=True
),
to_name,
)
child_name = to_field.related_name or child.get_name() + "s"
child = proxy(child)
elif virtual:
child_name, to_name = to_name, child_name or child.get_name()