$npx skillfedfor your agent

django-tree-queries

Tree queries with explicit opt-in, without configurability

Worth itPyPI Software DevelopmentReleased Mar 2026236.0K downloads / moBSD-3-ClausePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_tree_queries-0.24.0-py3-none-any.whl
v0.24.0 · released 2026-03-25 · Python >=3.8

Yes. The package is actively maintained, has no security vulnerabilities, installs with zero dependencies, and solves a real problem with a clean, opinionated design. It is suitable for any Django project needing hierarchical data queries on supported databases. The 50-level limit on MySQL/MariaDB is a documented trade-off; verify it fits your use case before committing.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Django 3.2 or better and Python 3.8 or better; MySQL/MariaDB trees limited to 50 levels maximum; parent foreign key must be named 'parent'.
  • Low friction install with no runtime dependencies.
  • Actively maintained, with last commit on 2026-08-14 and 516 repository stars indicating stable community adoption.

License · maintenance · safety

BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

last release 2026-03-25 (142 days) · last repo commit 2026-08-14 · 516 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 236,026 downloads/mo, #8,991 on PyPI

Verify before relying

pip install django-tree-queries

from django_tree_queries.models import TreeNode
import django.db.models as models

class Node(TreeNode):
    name = models.CharField(max_length=100)

nodes = Node.objects.with_tree_fields()
for node in nodes:
    print(node.tree_depth, node.tree_path)
  • Whether the performance optimization for simple cases delivers measurable improvement in typical workloads.
  • Real-world experience with the 50-level depth limit on MySQL/MariaDB and whether it affects common use cases.
  • Support for integer and UUID primary keys only—whether this limitation affects your existing models.
Same gist for agents: .md · .json

What it is and what it does

django-tree-queries adds efficient tree querying to Django models using recursive common table expressions instead of materialized path or nested set approaches. It extends Django querysets with methods to add computed columns (tree_depth, tree_path, tree_ordering) and control sibling ordering. The package supports PostgreSQL, SQLite (3.8.3 or higher), MySQL (8.0 or higher), and MariaDB (10.2.2 or higher), with automatic optimization for simple queries that avoids creating intermediate rank tables.

The library enforces a minimal design: parent foreign keys must be named "parent", primary keys must be integer or UUID, and tree depth is correctly defined with root nodes at depth zero. It includes an abstract model class with built-in loop protection and a variant for automatic sibling position management. The approach trades configurability for simplicity and performance, avoiding the complexity and data redundancy of other tree libraries.

Use it for

  • Build category hierarchies or organizational charts where you need to fetch all ancestors or descendants of a node efficiently.
  • Implement breadcrumb navigation or tree views that require depth-first ordering and path information for each node.
  • Manage nested comment threads or forum structures with automatic depth calculation and sibling ordering.
  • Query large hierarchical datasets while avoiding N+1 query problems through recursive common table expressions.
  • Reorder sibling nodes in a tree without recalculating the entire structure using automatic position management.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

The package is actively maintained, has no security vulnerabilities, installs with zero dependencies, and solves a real problem with a clean, opinionated design. It is suitable for any Django project needing hierarchical data queries on supported databases. The 50-level limit on MySQL/MariaDB is a documented trade-off; verify it fits your use case before committing.

Install

django-tree-queries on PyPI

Before you install

Low friction install with no runtime dependencies. Actively maintained, with last commit on 2026-08-14 and 516 repository stars indicating stable community adoption.

Requires Django 3.2 or better and Python 3.8 or better; MySQL/MariaDB trees limited to 50 levels maximum; parent foreign key must be named 'parent'.

License in practice

BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install django-tree-queries

from django_tree_queries.models import TreeNode
import django.db.models as models

class Node(TreeNode):
    name = models.CharField(max_length=100)

nodes = Node.objects.with_tree_fields()
for node in nodes:
    print(node.tree_depth, node.tree_path)

Verify before relying

  • Whether the performance optimization for simple cases delivers measurable improvement in typical workloads.
  • Real-world experience with the 50-level depth limit on MySQL/MariaDB and whether it affects common use cases.
  • Support for integer and UUID primary keys only—whether this limitation affects your existing models.

Package facts

LicenseBSD-3-Clause permissive
Python supportSupports the current Python release >=3.8
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceActively maintained 142 days since the last release
Last repo commit
First released
Downloads236,026 / month, #8,991 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Environment :: Web EnvironmentFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development

Evidence: django_tree_queries-0.24.0-py3-none-any.whl

Tags

Capabilities
django tree querieshierarchical data djangorecursive cte djangoadjacency list queriesnested tree structuresparent-child relationshipstree depth ordering
Topics
django-ormhierarchical-datadatabase-queries

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “django tree queries”

  • django-tree-queriesQuery hierarchical tree structures in Django models using recursive…
  • django-modeltreeProvides a simplified interface for navigating Django model…
  • rulesrules provides object-level permission checking for Django…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also django-cte · django-sql-utils · anytree · drf-writable-nested · django-ordered-model · django-mysql · django-modelcluster · treelib · drf-nested-routers · django-nonrelated-inlines