intorduce relation flags on basefield and simplify imports

This commit is contained in:
collerek
2021-02-21 17:46:06 +01:00
parent c560245760
commit e697235172
27 changed files with 163 additions and 149 deletions

View File

@ -36,9 +36,13 @@ class BaseField(FieldInfo):
index: bool
unique: bool
pydantic_only: bool
virtual: bool = False
choices: typing.Sequence
virtual: bool = False # ManyToManyFields and reverse ForeignKeyFields
is_multi: bool = False # ManyToManyField
is_relation: bool = False # ForeignKeyField + subclasses
is_through: bool = False # ThroughFields
owner: Type["Model"]
to: Type["Model"]
through: Type["Model"]
@ -62,7 +66,7 @@ class BaseField(FieldInfo):
:return: result of the check
:rtype: bool
"""
return not issubclass(cls, ormar.fields.ManyToManyField) and not cls.virtual
return not cls.is_multi and not cls.virtual
@classmethod
def get_alias(cls) -> str: