About this document
This document contains details about utilities which are used to implement certain features in Django MPTT, but which are suitable for re-use in your own applications, should the need arise.
Contents
The mptt.utils module contains the following functions for working with and creating lists of model instances which represent trees.
From http://www.wordaligned.org/articles/zippy-triples-served-with-python
Creates an iterator which returns (previous, current, next) triples, with None filling in when there is no previous or next available.
This function is useful if you want to step through a tree one item at a time and you need to refer to the previous or next item in the tree. It is used in the implementation of tree_item_iterator().
This function is used to implement the tree_info template filter, yielding two-tuples of (tree item, tree structure information dict).
See the tree_info documentation for more information.
This function is used in the implementation of the drilldown_tree_for_node template tag.
It creates an iterable which yields model instances representing a drilldown tree for a given node.
A drilldown tree consists of a node’s ancestors, itself and its immediate children, all in tree order.
Optional arguments may be given to specify details of a relationship between the given node’s class and another model class, for the purpose of adding related item counts to the node’s children.