LTreeField for Django
Project description
Minimalist Django Field for the PostgreSQL ltree Type.
django-ltree-field attempts to make very few assumptions about your use case.
For a higher level API based on django-ltree-field, consider using a prebuilt model from django-ltree-utils
Documentation
The full documentation is at https://django-ltree-field.readthedocs.io.
Quickstart
Install PostgreSQL LTreeField for Django:
pip install django-ltree-field
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_ltree_field',
...
)
Add an LTreeField to a new or existing model:
from django_ltree_field.fields import LTreeField
class MyModel(models.Model):
path = LTreeField(index=True, unique=True)
class Meta:
ordering = ['path']
Features
Implements only the bare minimum to make the ltree postgres type usuable
Does virtually no sanity checking. You can insert nodes without roots, and generally put the tree in a bad state
LTreeField accepts a string of dotted labels, or a list of labels
The ltree type is adapted to a python list
Does not implement an abstract “Node” model which has a nicer API (See django-ltree-utils for ready-made classes and managers)
Future Features?
Only minimal features required to make the field be reasonably usable will be added
Higher-level or richer features should be added to django-ltree-utils
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Development commands
pip install -r requirements_dev.txt invoke -l
Credits
Tools used in rendering this package:
History
0.1.0 (2021-03-24)
First release on PyPI.
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
Built Distribution
Hashes for django_ltree_field-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eede18671c6d37d848e6620c7b4c27f79d1d9b41005221916bc2ec123f3ba65 |
|
MD5 | 384b19434e38c29bc53a26a036102d3e |
|
BLAKE2b-256 | 155036637616671f5f8fd641d5ed54e9419928f67a70599e16e540bcf5221c8a |