I want to implement django recursive template rendering for getting users and their subordinates. However, I've got a ErrorRuntimeError at /admin/users/3 maximum recursion depth exceeded in instancecheck. I'm using django 1.9. The code is given below
The input is like that: [{name: 'user1@mail.com', id: 1, next: True},
{name: 'user2@mail.com', id: 2, next: True}, {name: 'user3@mail.com', id: 3, next: False}]
users_hierarchy.html
<ul>
{% for user in users %}
<li>{{ user.name }}</li>
{% if user.next %}
<ul>
{% include 'users/user_hierarchy.html' with data=user %}
</ul>
{% endif %}
{% endfor %}
I expect a html such as:
<ul>
<li>user1@mail.com
<ul>
<li>user2@mail.com
<ul>
<li>user3@mail.com</li>
</ul>
</li>
</ul>
</li>
What I am doing wrong?