I need to avoid cascading deletes on a foreign key, but it's a OneToOneField(), like:
class MyModel(models.Model):
def delete(self):
self.mysubmodel.clear() # Breaks because self.cartitem is not a QuerySet.
super(MyModel, self).delete()
class MySubModel(models.Model):
mymodel = models.OneToOneField(MyModel)
This version would work (but I can't use this version):
class MyModel(models.Model):
def delete(self):
self.mysubmodel_set.clear() # Works because self.mysubmodel_set is a QuerySet.
super(MyModel, self).delete()
class MySubModel(models.Model):
mymodel = models.ForeignKey(MyModel)