Say I have these models:
class MyModel(models.Model):
pass
class OtherModel(models.Model):
onetoone = OneToOneField(MyModel)
If obj
here is of type MyModel
, how can i then delete the onetoone
such that I can use the hasattr
-check later to find out that the onetoone does not exist any more?
Is there some other way to find out that the onetoone
has been deleted?
obj.onetoone.delete()
hasattr(obj, "onetoone") # This still returns True, but actually it should return False