{ "info": { "author": "Diederik van der Boor", "author_email": "opensource@edoburu.nl", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.4", "Framework :: Django :: 1.5", "Framework :: Django :: 1.6", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "django-polymorphic-tree\n=======================\n\n.. image:: https://img.shields.io/travis/edoburu/django-polymorphic-tree/master.svg?branch=master\n :target: http://travis-ci.org/edoburu/django-polymorphic-tree\n.. image:: https://img.shields.io/pypi/v/django-polymorphic-tree.svg\n :target: https://pypi.python.org/pypi/django-polymorphic-tree/\n.. image:: https://img.shields.io/pypi/dm/django-polymorphic-tree.svg\n :target: https://pypi.python.org/pypi/django-polymorphic-tree/\n.. image:: https://img.shields.io/badge/wheel-yes-green.svg\n :target: https://pypi.python.org/pypi/django-polymorphic-tree/\n.. image:: https://img.shields.io/pypi/l/django-polymorphic-tree.svg\n :target: https://pypi.python.org/pypi/django-polymorphic-tree/\n.. image:: https://img.shields.io/codecov/c/github/edoburu/django-polymorphic-tree/master.svg\n :target: https://codecov.io/github/edoburu/django-polymorphic-tree?branch=master\n\nThis package combines django-mptt_ with django-polymorphic_.\n\nIn other words, this module provides a node tree, where each node can be a different model type.\nThis allows you to freely structure tree data. For example:\n\n* Build a tree of a root node, category nodes, leaf nodes, each with custom fields.\n* Build a todo list of projects, categories and items.\n* Build a book of chapters, sections, and pages.\n\nOrigin\n------\n\nThis module was extracted out of django-fluent-pages_ because it turned out to serve a generic purpose.\nThis was done during contract work at Leukeleu_ (also known for their involvement in django-fiber_).\n\n\nInstallation\n============\n\nFirst install the module, preferably in a virtual environment::\n\n pip install django-polymorphic-tree\n\nOr install the current repository::\n\n pip install -e git+https://github.com/edoburu/django-polymorphic-tree.git#egg=django-polymorphic-tree\n\nThe main dependencies are django-mptt_ and django-polymorphic_,\nwhich will be automatically installed.\n\nConfiguration\n-------------\n\nNext, create a project which uses the application::\n\n cd ..\n django-admin.py startproject demo\n\nAdd the following to ``settings.py``:\n\n.. code:: python\n\n INSTALLED_APPS += (\n 'polymorphic_tree',\n 'polymorphic',\n 'mptt',\n )\n\n\nUsage\n-----\n\nThe main feature of this module is creating a tree of custom node types.\nIt boils down to creating a application with 2 files:\n\nThe ``models.py`` file should define the custom node type, and any fields it has:\n\n.. code:: python\n\n from django.db import models\n from django.utils.translation import ugettext_lazy as _\n from polymorphic_tree.models import PolymorphicMPTTModel, PolymorphicTreeForeignKey\n\n\n # A base model for the tree:\n\n class BaseTreeNode(PolymorphicMPTTModel):\n parent = PolymorphicTreeForeignKey('self', blank=True, null=True, related_name='children', verbose_name=_('parent'))\n title = models.CharField(_(\"Title\"), max_length=200)\n\n class Meta(PolymorphicMPTTModel.Meta):\n verbose_name = _(\"Tree node\")\n verbose_name_plural = _(\"Tree nodes\")\n\n\n # Create 3 derived models for the tree nodes:\n\n class CategoryNode(BaseTreeNode):\n opening_title = models.CharField(_(\"Opening title\"), max_length=200)\n opening_image = models.ImageField(_(\"Opening image\"), upload_to='images')\n\n class Meta:\n verbose_name = _(\"Category node\")\n verbose_name_plural = _(\"Category nodes\")\n\n\n class TextNode(BaseTreeNode):\n extra_text = models.TextField()\n\n # Extra settings:\n can_have_children = False\n\n class Meta:\n verbose_name = _(\"Text node\")\n verbose_name_plural = _(\"Text nodes\")\n\n\n class ImageNode(BaseTreeNode):\n image = models.ImageField(_(\"Image\"), upload_to='images')\n\n class Meta:\n verbose_name = _(\"Image node\")\n verbose_name_plural = _(\"Image nodes\")\n\n\nThe ``admin.py`` file should define the admin, both for the child nodes and parent:\n\n.. code:: python\n\n from django.contrib import admin\n from django.utils.translation import ugettext_lazy as _\n from polymorphic_tree.admin import PolymorphicMPTTParentModelAdmin, PolymorphicMPTTChildModelAdmin\n from . import models\n\n\n # The common admin functionality for all derived models:\n\n class BaseChildAdmin(PolymorphicMPTTChildModelAdmin):\n GENERAL_FIELDSET = (None, {\n 'fields': ('parent', 'title'),\n })\n\n base_model = models.BaseTreeNode\n base_fieldsets = (\n GENERAL_FIELDSET,\n )\n\n\n # Optionally some custom admin code\n\n class TextNodeAdmin(BaseChildAdmin):\n pass\n\n\n # Create the parent admin that combines it all:\n\n class TreeNodeParentAdmin(PolymorphicMPTTParentModelAdmin):\n base_model = models.BaseTreeNode\n child_models = (\n (models.CategoryNode, BaseChildAdmin),\n (models.TextNode, TextNodeAdmin), # custom admin allows custom edit/delete view.\n (models.ImageNode, BaseChildAdmin),\n )\n\n list_display = ('title', 'actions_column',)\n\n class Media:\n css = {\n 'all': ('admin/treenode/admin.css',)\n }\n\n\n admin.site.register(models.BaseTreeNode, TreeNodeParentAdmin)\n\n\nThe ``child_models`` attribute defines which admin interface is loaded for the *edit* and *delete* page.\nThe list view is still rendered by the parent admin.\n\n\nTests\n-----\n\nTo run the included test suite, execute::\n\n ./runtests.py\n\nTo test support for multiple Python and Django versions, run tox from the repository root::\n\n pip install tox\n tox\n\nThe Python versions need to be installed at your system. See pyenv (Linux) or Homebrew (Mac OS X).\n\nPython 2.6, 2.7, and 3.3 are the currently supported versions.\n\n\nTodo\n----\n\n* Sphinx Documentation\n\n\nContributing\n------------\n\nThis module is designed to be generic. In case there is anything you didn't like about it,\nor think it's not flexible enough, please let us know. We'd love to improve it!\n\nIf you have any other valuable contribution, suggestion or idea,\nplease let us know as well because we will look into it.\nPull requests are welcome too. :-)\n\n\n.. _Leukeleu: http://www.leukeleu.nl/\n.. _django-fiber: https://github.com/ridethepony/django-fiber\n.. _django-fluent-pages: https://github.com/edoburu/django-fluent-pages\n.. _django-mptt: https://github.com/django-mptt/django-mptt\n.. _django-polymorphic: https://github.com/chrisglass/django_polymorphic", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/sigmacms/sigmacms-polymorphic-tree/zipball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sigmacms/sigmacms-polymorphic-tree", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "sigmacms-polymorphic-tree", "package_url": "https://pypi.org/project/sigmacms-polymorphic-tree/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/sigmacms-polymorphic-tree/", "project_urls": { "Download": "https://github.com/sigmacms/sigmacms-polymorphic-tree/zipball/master", "Homepage": "https://github.com/sigmacms/sigmacms-polymorphic-tree" }, "release_url": "https://pypi.org/project/sigmacms-polymorphic-tree/1.2.6b1/", "requires_dist": null, "requires_python": null, "summary": "A polymorphic mptt structure to display content in a tree.", "version": "1.2.6b1" }, "last_serial": 4980614, "releases": { "1.2.6b0": [ { "comment_text": "", "digests": { "md5": "b7f7ce811c48a09c1447daa85e04a7c5", "sha256": "197f1bd21a8dca7340e2b8302c374b5baed584a63e9d523763ed1887d6053527" }, "downloads": -1, "filename": "sigmacms_polymorphic_tree-1.2.6b0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "b7f7ce811c48a09c1447daa85e04a7c5", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 47054, "upload_time": "2016-06-14T06:13:23", "url": "https://files.pythonhosted.org/packages/fa/eb/ec49957a2c214d752c6e9be786ab4abf0f915bc834a2cc525d5d19f3c2a0/sigmacms_polymorphic_tree-1.2.6b0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "feab59a2bc69b40458b8b6ebba74e14f", "sha256": "f38a24b7f00ba8f75f39e3e5cfcae7844713861951d649df53a5bb53ce9f665a" }, "downloads": -1, "filename": "sigmacms-polymorphic-tree-1.2.6b0.tar.gz", "has_sig": true, "md5_digest": "feab59a2bc69b40458b8b6ebba74e14f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39443, "upload_time": "2016-06-14T06:12:29", "url": "https://files.pythonhosted.org/packages/c1/ea/81f2d5309a9d2cc0ed926252767941a0ef4aca313f03f1ec39597e22966c/sigmacms-polymorphic-tree-1.2.6b0.tar.gz" } ], "1.2.6b1": [ { "comment_text": "", "digests": { "md5": "ea24687b6f9c5e1157c61633c33fa683", "sha256": "256dd2c7ffa495bf907136409fae9ca3cadf53bcfd4338afb83d0784316631ec" }, "downloads": -1, "filename": "sigmacms_polymorphic_tree-1.2.6b1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "ea24687b6f9c5e1157c61633c33fa683", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 47063, "upload_time": "2016-06-14T11:21:02", "url": "https://files.pythonhosted.org/packages/07/c6/d9cd27816372dc7e9829a60a9371ea70c08018f5654ec5bb93394b58c175/sigmacms_polymorphic_tree-1.2.6b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01c7062438fb50cb13c9cd0e79f29707", "sha256": "b1e6d3770b1db02ac4e761435cbfa08e82342e69e68edc55fc574c8f95bff855" }, "downloads": -1, "filename": "sigmacms-polymorphic-tree-1.2.6b1.tar.gz", "has_sig": true, "md5_digest": "01c7062438fb50cb13c9cd0e79f29707", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39458, "upload_time": "2016-06-14T11:20:40", "url": "https://files.pythonhosted.org/packages/0b/ed/9c4208b5b248d7c9e738d8cb5702f5373715ecc2093c9ddf62f6a05d898b/sigmacms-polymorphic-tree-1.2.6b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ea24687b6f9c5e1157c61633c33fa683", "sha256": "256dd2c7ffa495bf907136409fae9ca3cadf53bcfd4338afb83d0784316631ec" }, "downloads": -1, "filename": "sigmacms_polymorphic_tree-1.2.6b1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "ea24687b6f9c5e1157c61633c33fa683", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 47063, "upload_time": "2016-06-14T11:21:02", "url": "https://files.pythonhosted.org/packages/07/c6/d9cd27816372dc7e9829a60a9371ea70c08018f5654ec5bb93394b58c175/sigmacms_polymorphic_tree-1.2.6b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "01c7062438fb50cb13c9cd0e79f29707", "sha256": "b1e6d3770b1db02ac4e761435cbfa08e82342e69e68edc55fc574c8f95bff855" }, "downloads": -1, "filename": "sigmacms-polymorphic-tree-1.2.6b1.tar.gz", "has_sig": true, "md5_digest": "01c7062438fb50cb13c9cd0e79f29707", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39458, "upload_time": "2016-06-14T11:20:40", "url": "https://files.pythonhosted.org/packages/0b/ed/9c4208b5b248d7c9e738d8cb5702f5373715ecc2093c9ddf62f6a05d898b/sigmacms-polymorphic-tree-1.2.6b1.tar.gz" } ] }