[Fixed]-Django: calling parent variable on django models

1👍

From this model fields, your child has multiple parents and you can take the first parent name as;

def save(self, *args, **kwargs):
    self.name = self.parent_set.all()[0].parent_name
    super(Child, self).save(*args, **kwargs)

Leave a comment