1
You don’t want to create a new entry, since that will always lead to an infinite recursion. You just want to set self.parent
, then call the superclass save method:
def save(self, *args, **kwargs):
if not self.parent:
self.parent = M2.objects.get(name=self.m1.m1title)
return super(M2, self).save(*args, **kwargs)
Source:stackexchange.com