switch from class to instance fro fields

This commit is contained in:
collerek
2021-03-19 14:22:31 +01:00
parent 61c456a01f
commit 32695ffa1d
26 changed files with 329 additions and 411 deletions

View File

@ -1,4 +1,3 @@
import inspect
from typing import (
Callable,
List,
@ -9,6 +8,8 @@ from typing import (
Union,
)
from ormar import BaseField
class RelationMixin:
"""
@ -85,7 +86,11 @@ class RelationMixin:
related_names = set()
for name, field in cls.Meta.model_fields.items():
if inspect.isclass(field) and field.is_relation and not field.is_through:
if (
isinstance(field, BaseField)
and field.is_relation
and not field.is_through
):
related_names.add(name)
cls._related_names = related_names