first passing to clean and check
This commit is contained in:
@ -89,13 +89,13 @@ def register_reverse_model_fields(
|
||||
) -> None:
|
||||
if issubclass(model_field, ManyToManyField):
|
||||
model.Meta.model_fields[child_model_name] = ManyToMany(
|
||||
child, through=model_field.through, name=child_model_name, virtual=True
|
||||
child, through=model_field.through, name=child_model_name, virtual=True, related_name=model_field.name
|
||||
)
|
||||
# register foreign keys on through model
|
||||
adjust_through_many_to_many_model(model, child, model_field)
|
||||
else:
|
||||
model.Meta.model_fields[child_model_name] = ForeignKey(
|
||||
child, real_name=child_model_name, virtual=True
|
||||
child, real_name=child_model_name, virtual=True, related_name=model_field.name
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -62,10 +62,11 @@ class ModelTableProxy:
|
||||
|
||||
@staticmethod
|
||||
def get_clause_target_and_filter_column_name(
|
||||
parent_model: Type["Model"], target_model: Type["Model"], reverse: bool
|
||||
parent_model: Type["Model"], target_model: Type["Model"], reverse: bool, related: str,
|
||||
) -> Tuple[Type["Model"], str]:
|
||||
if reverse:
|
||||
field = target_model.resolve_relation_field(target_model, parent_model)
|
||||
field = parent_model.Meta.model_fields[related]
|
||||
# field = target_model.resolve_relation_field(target_model, parent_model)
|
||||
if issubclass(field, ormar.fields.ManyToManyField):
|
||||
sub_field = target_model.resolve_relation_field(
|
||||
field.through, parent_model
|
||||
|
||||
Reference in New Issue
Block a user