How can create a json tree from django-mptt?
问题 I want to use the JavaScript InfoVis Tooljit ( http://thejit.org ) to render a tree of mptt nodes in django. How can i create the required json structure (see http://thejit.org/static/v20/Jit/Examples/Spacetree/example1.code.html for an example) in django? Thanks 回答1: If you use the template functionality of django-mptt to generate the JSON data you should be able to do something like the following: var json = {% recursetree nodes %} { id: "{{ node.id }}", name: "{{ node.name }}", data: {},