Skip to main content

A Closure based Tree model for Django.

Project description

Django closure tree model.

Abstract base model for creating a Closure Tree using a recursive Postgres view.

http://schinckel.net/2016/01/27/django-trees-via-closure-view/

Usage

Inherit from the Node model:

from closure_tree.models import Node


class MyNode(Node):
    name = models.CharField(max_length=30)

Create migrations:

$ ./manage.py makemigrations

Add the CreateTreeClosure migration step:

$ ./manage.py makemigrations --empty myapp
from closure_tree.migrations import CreateTreeClosure

class Migration(migrations.Migration):

    dependencies = [
        ('dummy', '0001_initial'),
    ]

    operations = [
        CreateTreeClosure('MyNode'),
    ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-closure-tree-0.2.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

django_closure_tree-0.2.1-py2.py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page