How can I make hierarchy in django? I want to create a tree of Persons. I understand that I should add parent field to Person model. What do I need to change in model and view? Also I want to use tree-view to represent hierarchy.
class Person(models.Model):
name = models.CharField(max_length=40)
def __str__(self):
return self.name
def add_person(request):
if(request.method == 'POST'):
name = request.POST['name']
person = Person(name=name)
person.save()
return redirect('/persons')
else:
return render(request, 'add_person.html')