[Fixed]-Django concrete inheritance, __str__(self) in parent fails to pick attribute from child

1👍

This is the wrong way round. If your method is referencing an attribute that only exists on the child model, then it should be on that child model. As a bonus, that makes the logic a lot simpler:

class Client:
    def name(self):
        return self.First_Name + " " + self.Last_Name

class Individual(Client):
    def name(self):
        return self.First_Name + " " + self.Middle_Name + " " + self.Last_Name

Leave a comment