Requirements
Python 3.6+
A supported version of Django (currently 3.x)
Getting It
You can get Django tree materialized by using pip:
$ pip install django-tree-materialized
If you want to install it from source, grab the git repository from GitHub and run setup.py:
$ git clone git://github.com/kostya-ten/django_tree_materialized.git $ cd django_tree_materialized $ python setup.py install
Installation
To enable django_tree_materialized in your project you need to add it to INSTALLED_APPS in your projects settings.py
INSTALLED_APPS = (
# ...
'django_tree_materialized',
# ...
)
Using
Add to your models.py
from django_tree_materialized.models import MPTree
class YouModel(MPTree):
name = models.CharField(max_length=200)
Simple example
name = models.YouModel.create(name="Name name")
sub = models.YouModel.create(name="Name node2", parent=name)
# Get a list of parents
result = name.get_family() # Return QuerySet object
for item in result:
print(item.id, item.name, item.level, item.path, item.parent)
Method
get_family() - Get a list of parents
get_parent() - Return parent
get_root() - Return root object
move() - Moves one node to another
Move
name = models.YouModel.create(name="Name name")
new_name = models.YouModel.create(name="Name node2")
result = name.move(new_name) # Return QuerySet new_name object
Release files for django-tree-materialized 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-tree-materialized-0.0.6.tar.gz | 10.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_tree_materialized-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.6 kB
Release files / django-tree-materialized-0.0.6.tar.gz
| Download URL | django-tree-materialized-0.0.6.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6edfa607b99873f234594a20d751da76bb31471952690a0002becc384067fbc2
|
|
BLAKE2b-256 checksum How to use checksums |
ad354b7d030c5f7978db30d95e6e7b5a737be11c96805d8cc92904da42a47907
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Release files / django_tree_materialized-0.0.6-py3-none-any.whl
| Download URL | django_tree_materialized-0.0.6-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cd6790ad46c71d64620a803b30a169ccd305d7f065ff11fe0dc7965ea29a834
|
|
BLAKE2b-256 checksum How to use checksums |
d7bc1f5c5bf25ef104e4bcfcbf18026ac860175a9234ecef091b5ed1b42fcb44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|