Probably the best abstract model/admin for your tree based stuff. Provides a Django model and admin mixin for managing tree structures using Materialized Path. Current version 0.24.0 supports Django 3.2–6.0 and Python 3.7–3.14. Released regularly, with recent versions adding Django 6.0 and Python 3.14 support.
pip install django-treenodeVerified import paths — ran on the pinned version, not inferred.
Define a tree model by subclassing TreeNodeModel and adding a tn_parent ForeignKey. The model automatically gets fields like tn_priority, tn_order, tn_level, tn_count, etc.
Add a ForeignKey to self with related_name='children' and null=True, blank=True, and name it exactly 'tn_parent'.
Ensure Django's cache framework is configured (e.g., CACHES setting). If you don't need caching, set a dummy cache.
Upgrade to 0.23.3 or later.
Upgrade to 0.20.2 or later.