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:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user