I have a model on Django that forms a tree like structure:
class Person(models.Model):
name = models.CharField(max_length = 255)
parent = models.ForeignKey(
'self',
on_delete=models.DO_NOTHING,
blank = True,
null = True,
limit_choices_to=????,
)
def __str__(self):
return self.name
So far everything works good, admin generates a form and I am able to add new persons to the database. My problem is on the parent relationship: how can I avoid a self reference? I am trying to use the limit_choices_to, but so far I could not figure out how to use it to solve this.
Thank you