django-modeltree
TODO
What it is and what it does
django-modeltree is a Django utility that simplifies navigation of model relationships by building a tree structure from your model layout. Instead of writing complex queries to traverse related models, you define the tree once and access related objects and their data through an elegant interface. It wraps Django's ORM and anytree to provide a more intuitive way to work with interconnected models.
The package targets developers working with Django projects that have intricate model relationships. It aims to reduce boilerplate query code and make relationship traversal more readable. With support for Django 2.2 through 6.0 and Python 3.7 through 3.13, it covers a wide range of modern Django deployments, though the aging maintenance status and low adoption suggest it may not receive timely updates for new Django releases.
Use it for:
- Navigate multi-level model relationships in a Django admin or API without writing nested select_related or prefetch_related chains.
- Build a tree representation of a hierarchical model structure (e.g., organizational units, category taxonomies) for efficient traversal.
- Simplify access to related objects when building reports or exports that require data from multiple connected models.
- Reduce ORM query complexity in views or serializers that need to fetch and display related model data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a simplified interface for navigating Django model relationships and accessing related objects without complex query building.
Yes, if your Django project has complex model relationships and you want to reduce query boilerplate—the low install friction and permissive license make it a low-risk addition. However, the aging maintenance status (last commit 2026-01-29, only 3 stars) suggests limited community support; verify that it meets your specific use case and that you're comfortable with potential delays in Django version compatibility updates.
Install
django-modeltree on PyPI
pip
pip install django-modeltreeuv
uv add django-modeltreepoetry
poetry add django-modeltreeInstalling django-modeltree
Before you install
Low install friction with a pure-Python wheel. Maintenance status is aging—last commit was 2026-01-29 and the package has only 3 GitHub stars, suggesting limited community adoption and potential for delayed updates.
License in practice
BSD License (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install django-modeltree
from django_modeltree import ModelTree
# Build a modeltree to navigate model relationships
tree = ModelTree(YourModel)
Requires Django and anytree as runtime dependencies; Django version support spans 2.2 through 6.0.
Verify before relying
- Whether the package handles circular relationships or complex many-to-many scenarios without performance degradation.
- Specific performance characteristics compared to standard Django ORM queries for large model hierarchies.
- Whether the package is actively maintained or if the aging status indicates it may not support future Django versions.
Package facts
| License | BSD License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, anytree |
| Maintenance | aging — 211 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 85,686/month — #13,905 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_modeltree-1.0.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
nutreeNutree provides a Python library for creating,…
permissive · top 5,000 on PyPI
django-reverse-adminAdds reverse inline support to Django admin for…
permissive · top 15,000 on PyPI
django-peeringdbProvides Django ORM models and admin interface…
permissive · top 15,000 on PyPI
django-diagramGenerates Entity Relationship Diagrams in…
unclear · top 15,000 on PyPI
django-clickWraps the click command-line library to let you…
permissive · top 15,000 on PyPI
simple-icd-10-cmProvides Python functions to validate,…
permissive · top 15,000 on PyPI
django-nonrelated-inlinesProvides Django admin inline classes that let…
permissive · top 15,000 on PyPI
drf-writable-nestedExtends Django REST Framework serializers to…
permissive · top 15,000 on PyPI
rest-framework-generic-relationsProvides Django REST Framework serializers that…
permissive · top 15,000 on PyPI
django-countriesProvides a Django model field for storing…
permissive · top 5,000 on PyPI