0

I am using django-mptt and jquery-treetable.

I am printing my objects with:

<table>
{% for node in nodes %}
    <tr>
        <td>{{ node }}</td>
    </tr>
{% endfor %}
</table>

In jquery-treetable the <tr> element should have some attributes to identify which rows are children of which rows.

It needs to have the following setup

<table>
    <tr data-tt-id="1">
        <td>Parent</td>
    </tr>
    <tr data-tt-id="2" data-tt-parent-id="1">
        <td>Child</td>
    </tr>
</table>

but I can't seem to find the right template variables to identify the children correctly. I have only found node.id, node.tree_id, node.level, node.lft, and node.rght.

Jamgreen
  • 10,329
  • 29
  • 113
  • 224

1 Answers1

1

If your nodes are MPTTModels then you should have a 'parent' relationship to 'self'. Assuming that is the case, you should be able to get the parent id by doing:

node.parent.id
musashiXXX
  • 4,192
  • 4
  • 22
  • 24