fix setting new related model just from dict with pkname

This commit is contained in:
collerek
2020-08-23 13:15:04 +02:00
parent 53384879a9
commit 806fe9b63e
4 changed files with 7 additions and 3 deletions

View File

@ -87,6 +87,8 @@ class ForeignKeyField(BaseField):
@classmethod
def _construct_model_from_dict(cls, value: dict, child: "Model") -> "Model":
if len(value.keys()) == 1 and list(value.keys())[0] == cls.to.Meta.pkname:
value["__pk_only__"] = True
model = cls.to(**value)
cls.register_relation(model, child)
return model