1👍
✅
To delete the customer
when you delete a calculation
:
def delete(self, *args, **kwargs):
self.customer.delete()
super(Calculations, self).delete(*args, **kwargs)
To avoid deleting the calculation
when you delete a customer
:
customer = models.ForeignKey(to=Customer, null=True, blank=True, on_delete=models.SET_NULL)
Source:stackexchange.com