i have a model like this
class Unit(models.ModelForm):
Name = models.CharField(max_length = 100)
Parent = models.ForeignKey('self' , on_delete=models.CASCADE , related_name = 'SubUnits')
i want to show hierarchy tree with ul and li
in the template.
first of all in the views.py
i passed all Units with no parent which considered as Root Objects and then with a custom filter tag
i want to generate hierarchy ul li tree
object1 ----|object 1.1
|object 1.2------| object 1.2.1
|object 1.3
objecte 2
object 3 ---| object 3.1
| object 3.2---| object 3.2.1
in my custom tag i looks for a function that can generate infinite parent and child ul li for my root object.