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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file django-orderable-tree-0.1.0.tar.gz.

File metadata

  • Download URL: django-orderable-tree-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for django-orderable-tree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b308fd5ff9af4fdc6f8d2687f0843d4d0de2507e615983467c324301424cc1f
MD5 54212844d4d7fde0d0b615d4c41d69e1
BLAKE2b-256 14d227e7713ad1bad03ef66060ec9445ddfdd162f54f13d20fbd074d9d347f14

See more details on using hashes here.

Provenance

File details

Details for the file django_orderable_tree-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_orderable_tree-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cabb36a6b037de542f6d91094330ee7d6c41686d9288f943470e06969579e71d
MD5 71ae6c2fb6163de83d1d71d170776285
BLAKE2b-256 bd7b12bbe3424eff97a3dc0eacc31b0286b034a287653124667a6c80dc7ec1b7

See more details on using hashes here.

Provenance

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