{"repo":"mariocesar/django-ltree","free":true,"listed":false,"github":"https://github.com/mariocesar/django-ltree","clone":"git clone https://github.com/mariocesar/django-ltree.git","description":"An ltree extension implementation to support hierarchical tree-like data using the native Postgres extension ltree in django models","language":"Python","stars":75,"topics":["django","ltree","postgresql-extension"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"django-ltree A Django implementation for PostgreSQL's ltree extension, providing efficient storage and querying of hierarchical tree-like data. See PostgreSQL's ltree documentation to learn more about it. The main benefits of ltree : - Efficient path queries (ancestors, descendants, pattern matching) - Index-friendly hierarchical storage - Powerful label path searching - Native PostgreSQL performance for tree operations Features - Django model fields for ltree data types - Query utilities for common tree operations - Migration support for ltree extension installation - Compatibility with Django's ORM and query syntax Requirements - Django 5.2+ - Python 3.11+ - PostgreSQL 14+ (with ltree extension enabled) Installation 1. Install the package: 2. Add to your INSTALLED APPS : 3. Run migrations to install the ltree extension: Usage django-ltree provides a base model class called TreeModel . TreeModel does these things out of the box: - adds a field called path to your model (by default, path is created by items Id plus parent's path) - adds t objects which is the TreeManager you can use to work with tree data - adds two indexes for path (one BTreeIndex , one GistIndex ) - orders items base on path if you are overriding the Meta class of your model, you may want to inherit from TreeModel.Meta. to keep the indexes and ordering. Quick Start 1. inherit from TreeModel: 2. Create tree nodes: note that path is handled by django-ltree , you don't need to pass any value for it 3. Query an","default_branch":null,"files":null,"tree":[],"storefront":"/r/mariocesar","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mariocesar/django-ltree/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}