Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
3This is a simplistic implementation of tree-like functionality using only a ``parent`` field that refers to ``self``.
4It performs well for a relatively small number of records. For thousands records, you may wish to review the following
5resources:
7- `MPTT`_
8- `Treebeard`_
10.. _MPTT: https://django-mptt.readthedocs.io/en/latest/index.html
11.. _Treebeard: http://django-treebeard.readthedocs.io/en/latest/index.html
13Graphing
14--------
16Parent-tree provides a utility for creating a visual graph of a given record and all of its children.
18.. important::
19 The ``anytree`` package is required to utilize this functionality.
21The :py:class:`superdjango.db.parent.utils.Diagram` class may be used to create an image. Suppose you have an HR tool
22and you want to present the structure of an organization:
24.. code-block:: python
26 from django.conf import settings
27 import os
28 from superdjango.db.parent.utils import Diagram
29 from hr.organizations.models import Organization
31 # Load the graphing utility.
32 org = Organization.objects.get(pk=1)
33 diagram = Diagram(org)
35 # Output the image.
36 graph = diagram.to_graph()
37 path = os.path.join(settings.MEDIA_ROOT, "hr", "orgs", "%s.jpg" % org.pk)
38 graph.to_picture(path)
40"""
41__author__ = "Shawn Davis <shawn@superdjango.com>"
42__maintainer__ = "Shawn Davis <shawn@superdjango.com>"
43__version__ = "0.7.0-x"