WIP skip relation registration on m2m through instance, simplify registering relations part 2
This commit is contained in:
@ -63,7 +63,7 @@ class Relation:
|
||||
self._type: RelationType = type_
|
||||
self._to_remove: Set = set()
|
||||
self.to: Type["T"] = to
|
||||
self.through: Optional[Type["T"]] = through
|
||||
self._through: Optional[Type["T"]] = through
|
||||
self.field_name = field_name
|
||||
self.related_models: Optional[Union[RelationProxy, "T"]] = (
|
||||
RelationProxy(relation=self, type_=type_, field_name=field_name)
|
||||
@ -71,6 +71,12 @@ class Relation:
|
||||
else None
|
||||
)
|
||||
|
||||
@property
|
||||
def through(self) -> Type["T"]:
|
||||
if not self._through: # pragma: no cover
|
||||
raise RelationshipInstanceError("Relation does not have through model!")
|
||||
return self._through
|
||||
|
||||
def _clean_related(self) -> None:
|
||||
"""
|
||||
Removes dead weakrefs from RelationProxy.
|
||||
|
||||
Reference in New Issue
Block a user