{ "info": { "author": "imtapps", "author_email": "serveradmin@imtapps.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Database", "Topic :: Software Development :: Libraries" ], "description": "django_trees\n============\n\n.. image:: https://travis-ci.org/imtapps/django-trees.svg?branch=master\n :target: https://travis-ci.org/imtapps/django-trees\n\nSimple way to create, persist and manipulate reliable tree structures using Django models.\n\n\nInstallation\n============\n\n``pip install django-trees``\n\n\nAPI Usage\n=========\n\nCreate Model\n------------\n\nTo create a model extend ``AbstractNode`` and add desired fields.\n\n.. code:: python\n\n from django.db import models\n from django_trees.models import AbstractNode\n \n class Folder(AbstractNode):\n name = models.CharField(max_length=10)\n\n\nCreate Tree Nodes\n-----------------\n\nTo create a tree node, there is nothing different than creating a normal Django model other than you may specify a parent node.\n\n.. code:: python\n\n root = Folder.objects.create(name=\"Root\")\n documents = Folder.objects.create(name=\"Documents\", parent=root)\n downloads = Folder.objects.create(name=\"Downloads\", parent=root)\n projects = Folder.objects.create(name=\"Projects\", parent=documents)\n\n\nGet Node Descendants\n--------------------\n\nTo retrieve all of the descendants of a node (including children, grandchildren, great grandchildren, etc) use the ``get_descendants`` method. This method will return a flat list of node objects.\n\n.. code:: python\n\n root.get_descendants() \n\n\nGet Node Ancestors\n------------------\n\nTo retrieve all of the ancestors of a node (including parents, grandparents, great grandparents, etc) use the ``get_ancestors`` method. This method will return a flat list of node objects.\n\n.. code:: python\n\n projects.get_ancestors() \n\n\nGet Node Children\n-----------------\n\nTo retrieve all immediate children of the current node use the ``get_children`` method. This method will return a flat list of node objects.\n\n.. code:: python\n\n projects.get_children() \n\n\nMove Node\n---------\n\nTo move a node to a different position in the tree use the ``move`` method passing the new parent node as an argument.\n\n.. code:: python\n\n projects.move(root)\n\n\nBifurcate Node\n--------------\n\nTo create a separate tree from a branch of an existing tree use the ``bifurcate`` method. The node object will be removed from the previous tree and it along with its descendants will now be in a new tree.\n\n.. code:: python\n\n projects.bifurcate()\n\n\nGet ASCII Tree\n--------------\n\nTo get an ascii representation of the tree structure use the ``get_ascii_tree`` method.\n\n.. code:: python\n\n projects.get_ascii_tree()\n\n\nDemo\n----\n\n.. image:: https://cloud.githubusercontent.com/assets/847632/4188298/1d00fe0a-3771-11e4-8900-ccda9fbb72a1.gif", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/imtapps/django_trees", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django_trees", "package_url": "https://pypi.org/project/django_trees/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django_trees/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/imtapps/django_trees" }, "release_url": "https://pypi.org/project/django_trees/2.0.1/", "requires_dist": null, "requires_python": null, "summary": "Simple way to create, persist and manipulate reliable tree structures using Django models.", "version": "2.0.1" }, "last_serial": 1218554, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9c699996508ae9123190a33b5a81017c", "sha256": "c033e26478373510b758b61887dd799615568841259bd28ebbb7938947e0c2b3" }, "downloads": -1, "filename": "django_trees-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9c699996508ae9123190a33b5a81017c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9402, "upload_time": "2014-09-08T16:01:00", "url": "https://files.pythonhosted.org/packages/56/e2/7b31d964db84c19704317e1f2f3df30533493ea140c6ed5737ddd01edc50/django_trees-1.0.0.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "60f82893799cb66c54a4e0c49b8b07cf", "sha256": "fd356d7a19277bc20c2a851df2e24f151b7a6ce9930eb8a438925a93e2fdcf27" }, "downloads": -1, "filename": "django_trees-2.0.0.tar.gz", "has_sig": false, "md5_digest": "60f82893799cb66c54a4e0c49b8b07cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9352, "upload_time": "2014-09-08T21:02:09", "url": "https://files.pythonhosted.org/packages/0f/10/4c3c0e35bea2dfbc40e0df891fb9fa6767173f9e99b14fa7c707b01679ab/django_trees-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "d9a6f8d7258678641b0f5285d6479079", "sha256": "954795d223cc7bf6f8218477b2256cbba2cab5bec452433738c01af21c677180" }, "downloads": -1, "filename": "django_trees-2.0.1.tar.gz", "has_sig": false, "md5_digest": "d9a6f8d7258678641b0f5285d6479079", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9366, "upload_time": "2014-09-09T17:51:15", "url": "https://files.pythonhosted.org/packages/2e/db/f9f7a3ca906a1af576c47f4a9e5e25199214f8a419a036133098d5b76e24/django_trees-2.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d9a6f8d7258678641b0f5285d6479079", "sha256": "954795d223cc7bf6f8218477b2256cbba2cab5bec452433738c01af21c677180" }, "downloads": -1, "filename": "django_trees-2.0.1.tar.gz", "has_sig": false, "md5_digest": "d9a6f8d7258678641b0f5285d6479079", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9366, "upload_time": "2014-09-09T17:51:15", "url": "https://files.pythonhosted.org/packages/2e/db/f9f7a3ca906a1af576c47f4a9e5e25199214f8a419a036133098d5b76e24/django_trees-2.0.1.tar.gz" } ] }