Here is my model:
class Company(models.Model):
class Meta:
verbose_name_plural = "companies"
name = models.CharField(max_length=30)
parent = models.ForeignKey('self', blank=True, null=True, on_delete=models.SET_NULL)
def __str__(self):
return 'Company: %s' % self.name
Is there a way to modify the def __str__ method in order to display the children with a - or indent, depending on the relationship to it's parent? Like so:
Company A
- Company C
Company B
- Company D
- Company E
-- Company F