Skip to main content

Tree structure for hierarchical data

Project description

Django Tree

CI Test Coverage Maintainability

Overview

A tree structure for hierarchical data. Optimised for fast insertion/moving of nodes around the tree.

Requirements

  • Django 3.2+
  • Python 3.8+

Installation

  • Add django_tree to INSTALLED_APPS.

Usage

Simply extend the BaseTreeNode class in your application: e.g.

from django.db import models

from django_tree.models import BaseTreeNode


class Category(BaseTreeNode):
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

# Will contain an OrderedDict of categories organised into a tree structure.
categories = Category.objects.build_tree()

Testing

  1. Install dev dependencies: poetry install.
  2. Install a supported version of Django: pip install django==3.2
  3. Run the tests: DB_NAME="django_tree" python -m pytest tests .

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-orderable-tree-0.1.0.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

django_orderable_tree-0.1.0-py3-none-any.whl (12.2 kB view hashes)

Uploaded 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