no cyclic reference possible
This commit is contained in:
parent
174e62b316
commit
ec8e289ff8
1 changed files with 14 additions and 0 deletions
|
@ -30,6 +30,20 @@ class EquipmentCategory(models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.pk:
|
||||
done = False
|
||||
current = self
|
||||
while not done:
|
||||
if current.parent == self:
|
||||
self.parent = None
|
||||
done = True
|
||||
elif current.parent == None:
|
||||
done = True
|
||||
current = current.parent
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
class Equipment(EventSpecificMixin, models.Model):
|
||||
name = models.CharField(
|
||||
|
|
Loading…
Reference in a new issue