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
You need to have a reasonably updated version of postgres listening on port 5444. You can use docker-compose to start a server
- ::
docker-compose up
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -r requirements.txt -r requirements_test.txt --upgrade (myenv) $ python -Werror runtests.py
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
File details
Details for the file django-ltree-field-0.1.5.tar.gz
.
File metadata
- Download URL: django-ltree-field-0.1.5.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f610160c18d34c384eecb8f46b46483ca58459ec98706866b65ba3fdd531d3ea |
|
MD5 | a58e598f2b87f9ff264064be31ba2773 |
|
BLAKE2b-256 | cf42047ac842bd1a49687c9646cec138844f1e17b99557aa30efddba52816359 |
Provenance
File details
Details for the file django_ltree_field-0.1.5-py2.py3-none-any.whl
.
File metadata
- Download URL: django_ltree_field-0.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec5b05c20c3c01ca80b6b6aa8232c03a1cd87137c6681451ed551f958fea6be |
|
MD5 | 1a1e6f733425fb361f88d89a6f142169 |
|
BLAKE2b-256 | 697b1e34061b5414284aa9af4837bca4b8202cb4c022074a13f4bc54772daa34 |