django-fast-treenode 3.0.2__tar.gz → 3.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_fast_treenode-3.0.2/django_fast_treenode.egg-info → django_fast_treenode-3.0.4}/PKG-INFO +24 -25
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/README.md +22 -23
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4/django_fast_treenode.egg-info}/PKG-INFO +24 -25
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/django_fast_treenode.egg-info/requires.txt +1 -1
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/about.md +1 -1
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/index.md +3 -3
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/migration.md +4 -4
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/roadmap.md +19 -20
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/pyproject.toml +2 -2
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/setup.py +2 -2
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/admin.py +1 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/mixin.py +1 -1
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/managers/queries.py +6 -18
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/managers/tasks.py +80 -42
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/AUTHORS.txt +384 -384
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/LICENSE.txt +43 -43
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/external/jquery/jquery.js +10716 -10716
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/index.html +297 -297
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.css +438 -438
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.js +5222 -5222
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.min.css +6 -6
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.min.js +5 -5
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.structure.css +16 -16
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.structure.min.css +4 -4
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.theme.css +439 -439
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/jquery-ui.theme.min.css +4 -4
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/package.json +82 -82
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/sqlcompat.py +33 -1
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/sqlquery.py +24 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/version.py +2 -2
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/LICENSE +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/MANIFEST.in +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/django_fast_treenode.egg-info/SOURCES.txt +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/django_fast_treenode.egg-info/dependency_links.txt +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/django_fast_treenode.egg-info/top_level.txt +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/.gitignore +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/.nojekyll +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/admin.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/api.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/apifirst.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/cache.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/customization.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/dnd.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/import_export.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/insert-after.jpg +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/insert-as-child.jpg +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/installation.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/models.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/requirements.txt +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/docs/using.md +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/setup.cfg +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/tests/test_suite.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/changelist.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/exporter.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/admin/importer.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/apps.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/cache.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/forms.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/managers/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/managers/managers.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/decorators.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/factory.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/ancestors.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/children.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/descendants.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/family.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/logical.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/node.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/properties.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/roots.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/siblings.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/tree.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/mixins/update.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/models/models.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/settings.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/signals.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/.gitkeep +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/css/.gitkeep +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/css/tree_widget.css +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/css/treenode_admin.css +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/css/treenode_tabs.css +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/js/.gitkeep +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/js/lz-string.min.js +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/js/tree_widget.js +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/js/treenode_admin.js +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/static/vendors/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/.gitkeep +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/admin/.gitkeep +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/admin/treenode_ajax_rows.html +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/admin/treenode_changelist.html +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/admin/treenode_import_export.html +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/admin/treenode_rows.html +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/templates/widgets/tree_widget.html +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/tests.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/urls.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/compiler.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/db_vendor.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/utils/db/service.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/__init__.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/autoapi.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/autocomplete.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/children.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/common.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/crud.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/views/search.py +0 -0
- {django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4}/treenode/widgets.py +0 -0
{django_fast_treenode-3.0.2/django_fast_treenode.egg-info → django_fast_treenode-3.0.4}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: django-fast-treenode
|
3
|
-
Version: 3.0.
|
3
|
+
Version: 3.0.4
|
4
4
|
Summary: Treenode Framework for supporting tree (hierarchical) data structure in Django projects
|
5
5
|
Home-page: https://django-fast-treenode.readthedocs.io/
|
6
6
|
Author: Timur Kady
|
@@ -53,7 +53,7 @@ Classifier: Operating System :: OS Independent
|
|
53
53
|
Requires-Python: >=3.9
|
54
54
|
Description-Content-Type: text/markdown
|
55
55
|
License-File: LICENSE
|
56
|
-
Requires-Dist: Django>=
|
56
|
+
Requires-Dist: Django>=5.0
|
57
57
|
Requires-Dist: msgpack>=1.0.0
|
58
58
|
Requires-Dist: openpyxl>=3.0.0
|
59
59
|
Requires-Dist: pyyaml>=5.1
|
@@ -62,16 +62,16 @@ Dynamic: home-page
|
|
62
62
|
Dynamic: license-file
|
63
63
|
Dynamic: requires-python
|
64
64
|
|
65
|
-
#
|
65
|
+
# Treenode Framework
|
66
66
|
**A hybrid open-source framework for working with trees in Django**
|
67
67
|
|
68
68
|
[](https://github.com/TimurKady/django-fast-treenode/actions/workflows/test.yaml)
|
69
69
|
[](https://django-fast-treenode.readthedocs.io/)
|
70
|
-
[](https://pypi.org/project/django-fast-
|
70
|
+
[](https://pypi.org/project/django-fast-Treenode/)
|
71
71
|
[](https://djangopackages.org/packages/p/django-fast-treenode/)
|
72
72
|
[](https://github.com/sponsors/TimurKady)
|
73
73
|
|
74
|
-
## About The
|
74
|
+
## About The Treenode Framework
|
75
75
|
### Overview
|
76
76
|
|
77
77
|
**Treenode Framework** is an advanced tree management system for Django applications.It is designed to handle large-scale, deeply nested, and highly dynamic tree structures while maintaining excellent performance, data integrity, and ease of use.
|
@@ -87,7 +87,7 @@ Its core philosophy: **maximum scalability, minimum complexity**.
|
|
87
87
|
|
88
88
|
### Key Features
|
89
89
|
#### Common operations
|
90
|
-
The `django-fast-
|
90
|
+
The `django-fast-Treenode` package supports all the basic operations needed to work with tree structures:
|
91
91
|
|
92
92
|
- Extracting **ancestors** (queryset, list, pks, count);
|
93
93
|
- Extracting **children** (queryset, list, pks, count);
|
@@ -118,10 +118,10 @@ Typical applications include:
|
|
118
118
|
|
119
119
|
In all these domains, scalable and fast tree management is not a luxury — it's a necessity.
|
120
120
|
|
121
|
-
### Why
|
121
|
+
### Why Treenode Framework?
|
122
122
|
At the moment, django-fast-treeenode is, if not the best, then one of the best packages for working with tree data under Djangjo.
|
123
123
|
|
124
|
-
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-
|
124
|
+
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-Treenode`) shows **performance 4-7 times better** than the main popular packages.
|
125
125
|
- **Flexible API**: today contains the widest set of methods for working with a tree in comparison with other packages.
|
126
126
|
- **Convenient administration**: the admin panel interface was developed taking into account the experience of using other packages. It provides convenience and intuitiveness with ease of programming.
|
127
127
|
- **Scalability**: **Treenode Framework** suitable for solving simple problems such as menus, directories, parsing arithmetic expressions, as well as complex problems such as program optimization, image layout, multi-step decision making problems, or machine learning..
|
@@ -134,7 +134,7 @@ To get started quickly, you need to follow these steps:
|
|
134
134
|
|
135
135
|
- Simply install the package via `pip`:
|
136
136
|
```sh
|
137
|
-
pip install django-fast-
|
137
|
+
pip install django-fast-Treenode
|
138
138
|
```
|
139
139
|
- Once installed, add `'treenode'` to your `INSTALLED_APPS` in **settings.py**:
|
140
140
|
```python {title="settings.py"}
|
@@ -147,9 +147,9 @@ To get started quickly, you need to follow these steps:
|
|
147
147
|
|
148
148
|
- Open **models.py** and create your own tree class:
|
149
149
|
```
|
150
|
-
from
|
150
|
+
from Treenode.models import TreenodeModel
|
151
151
|
|
152
|
-
class MyTree(
|
152
|
+
class MyTree(TreenodeModel):
|
153
153
|
name = models.CharField(max_length=255)
|
154
154
|
display_field = "name"
|
155
155
|
```
|
@@ -157,11 +157,11 @@ To get started quickly, you need to follow these steps:
|
|
157
157
|
- Open **admin.py** and create a model for the admin panel
|
158
158
|
```
|
159
159
|
from django.contrib import admin
|
160
|
-
from
|
161
|
-
from .models import
|
160
|
+
from Treenode.admin import TreenodeModelAdmin
|
161
|
+
from .models import MyTree
|
162
162
|
|
163
|
-
@admin.register(
|
164
|
-
class
|
163
|
+
@admin.register(MyTree)
|
164
|
+
class MyTreeAdmin(TreenodeModelAdmin):
|
165
165
|
list_display = ("name",)
|
166
166
|
search_fields = ("name",)
|
167
167
|
```
|
@@ -176,25 +176,24 @@ To get started quickly, you need to follow these steps:
|
|
176
176
|
```sh
|
177
177
|
python manage.py runserver
|
178
178
|
```
|
179
|
-
|
180
179
|
Everything is ready, enjoy 🎉!
|
181
180
|
|
182
181
|
## Documentation
|
183
|
-
Full documentation is available at **[ReadTheDocs](https://django-fast-
|
182
|
+
Full documentation is available at **[ReadTheDocs](https://django-fast-Treenode.readthedocs.io/)**.
|
184
183
|
|
185
184
|
Quick access links:
|
186
|
-
* [Installation, configuration and fine tuning](https://django-fast-
|
187
|
-
* [Model Inheritance and Extensions](https://django-fast-
|
188
|
-
* [Working with Admin Classes](https://django-fast-
|
189
|
-
* [API Reference](https://django-fast-
|
190
|
-
* [Import & Export](https://django-fast-
|
191
|
-
* [Caching and working with cache](https://django-fast-
|
192
|
-
* [Migration and upgrade guide](https://django-fast-
|
185
|
+
* [Installation, configuration and fine tuning](https://django-fast-Treenode.readthedocs.io/installation/)
|
186
|
+
* [Model Inheritance and Extensions](https://django-fast-Treenode.readthedocs.io/models/)
|
187
|
+
* [Working with Admin Classes](https://django-fast-Treenode.readthedocs.io/admin/)
|
188
|
+
* [API Reference](https://django-fast-Treenode.readthedocs.io/api/)
|
189
|
+
* [Import & Export](https://django-fast-Treenode.readthedocs.io/import_export/)
|
190
|
+
* [Caching and working with cache](https://django-fast-Treenode.readthedocs.io/cache/)
|
191
|
+
* [Migration and upgrade guide](https://django-fast-Treenode.readthedocs.io/migration/)
|
193
192
|
|
194
193
|
Your wishes, objections, comments are welcome.
|
195
194
|
|
196
195
|
## License
|
197
|
-
Released under [MIT License](https://github.com/TimurKady/django-fast-
|
196
|
+
Released under [MIT License](https://github.com/TimurKady/django-fast-Treenode/blob/main/LICENSE).
|
198
197
|
|
199
198
|
## Credits
|
200
199
|
Thanks to everyone who contributed to the development and testing of this package, as well as the Django community for their inspiration and support.
|
@@ -1,13 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# Treenode Framework
|
2
2
|
**A hybrid open-source framework for working with trees in Django**
|
3
3
|
|
4
4
|
[](https://github.com/TimurKady/django-fast-treenode/actions/workflows/test.yaml)
|
5
5
|
[](https://django-fast-treenode.readthedocs.io/)
|
6
|
-
[](https://pypi.org/project/django-fast-
|
6
|
+
[](https://pypi.org/project/django-fast-Treenode/)
|
7
7
|
[](https://djangopackages.org/packages/p/django-fast-treenode/)
|
8
8
|
[](https://github.com/sponsors/TimurKady)
|
9
9
|
|
10
|
-
## About The
|
10
|
+
## About The Treenode Framework
|
11
11
|
### Overview
|
12
12
|
|
13
13
|
**Treenode Framework** is an advanced tree management system for Django applications.It is designed to handle large-scale, deeply nested, and highly dynamic tree structures while maintaining excellent performance, data integrity, and ease of use.
|
@@ -23,7 +23,7 @@ Its core philosophy: **maximum scalability, minimum complexity**.
|
|
23
23
|
|
24
24
|
### Key Features
|
25
25
|
#### Common operations
|
26
|
-
The `django-fast-
|
26
|
+
The `django-fast-Treenode` package supports all the basic operations needed to work with tree structures:
|
27
27
|
|
28
28
|
- Extracting **ancestors** (queryset, list, pks, count);
|
29
29
|
- Extracting **children** (queryset, list, pks, count);
|
@@ -54,10 +54,10 @@ Typical applications include:
|
|
54
54
|
|
55
55
|
In all these domains, scalable and fast tree management is not a luxury — it's a necessity.
|
56
56
|
|
57
|
-
### Why
|
57
|
+
### Why Treenode Framework?
|
58
58
|
At the moment, django-fast-treeenode is, if not the best, then one of the best packages for working with tree data under Djangjo.
|
59
59
|
|
60
|
-
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-
|
60
|
+
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-Treenode`) shows **performance 4-7 times better** than the main popular packages.
|
61
61
|
- **Flexible API**: today contains the widest set of methods for working with a tree in comparison with other packages.
|
62
62
|
- **Convenient administration**: the admin panel interface was developed taking into account the experience of using other packages. It provides convenience and intuitiveness with ease of programming.
|
63
63
|
- **Scalability**: **Treenode Framework** suitable for solving simple problems such as menus, directories, parsing arithmetic expressions, as well as complex problems such as program optimization, image layout, multi-step decision making problems, or machine learning..
|
@@ -70,7 +70,7 @@ To get started quickly, you need to follow these steps:
|
|
70
70
|
|
71
71
|
- Simply install the package via `pip`:
|
72
72
|
```sh
|
73
|
-
pip install django-fast-
|
73
|
+
pip install django-fast-Treenode
|
74
74
|
```
|
75
75
|
- Once installed, add `'treenode'` to your `INSTALLED_APPS` in **settings.py**:
|
76
76
|
```python {title="settings.py"}
|
@@ -83,9 +83,9 @@ To get started quickly, you need to follow these steps:
|
|
83
83
|
|
84
84
|
- Open **models.py** and create your own tree class:
|
85
85
|
```
|
86
|
-
from
|
86
|
+
from Treenode.models import TreenodeModel
|
87
87
|
|
88
|
-
class MyTree(
|
88
|
+
class MyTree(TreenodeModel):
|
89
89
|
name = models.CharField(max_length=255)
|
90
90
|
display_field = "name"
|
91
91
|
```
|
@@ -93,11 +93,11 @@ To get started quickly, you need to follow these steps:
|
|
93
93
|
- Open **admin.py** and create a model for the admin panel
|
94
94
|
```
|
95
95
|
from django.contrib import admin
|
96
|
-
from
|
97
|
-
from .models import
|
96
|
+
from Treenode.admin import TreenodeModelAdmin
|
97
|
+
from .models import MyTree
|
98
98
|
|
99
|
-
@admin.register(
|
100
|
-
class
|
99
|
+
@admin.register(MyTree)
|
100
|
+
class MyTreeAdmin(TreenodeModelAdmin):
|
101
101
|
list_display = ("name",)
|
102
102
|
search_fields = ("name",)
|
103
103
|
```
|
@@ -112,25 +112,24 @@ To get started quickly, you need to follow these steps:
|
|
112
112
|
```sh
|
113
113
|
python manage.py runserver
|
114
114
|
```
|
115
|
-
|
116
115
|
Everything is ready, enjoy 🎉!
|
117
116
|
|
118
117
|
## Documentation
|
119
|
-
Full documentation is available at **[ReadTheDocs](https://django-fast-
|
118
|
+
Full documentation is available at **[ReadTheDocs](https://django-fast-Treenode.readthedocs.io/)**.
|
120
119
|
|
121
120
|
Quick access links:
|
122
|
-
* [Installation, configuration and fine tuning](https://django-fast-
|
123
|
-
* [Model Inheritance and Extensions](https://django-fast-
|
124
|
-
* [Working with Admin Classes](https://django-fast-
|
125
|
-
* [API Reference](https://django-fast-
|
126
|
-
* [Import & Export](https://django-fast-
|
127
|
-
* [Caching and working with cache](https://django-fast-
|
128
|
-
* [Migration and upgrade guide](https://django-fast-
|
121
|
+
* [Installation, configuration and fine tuning](https://django-fast-Treenode.readthedocs.io/installation/)
|
122
|
+
* [Model Inheritance and Extensions](https://django-fast-Treenode.readthedocs.io/models/)
|
123
|
+
* [Working with Admin Classes](https://django-fast-Treenode.readthedocs.io/admin/)
|
124
|
+
* [API Reference](https://django-fast-Treenode.readthedocs.io/api/)
|
125
|
+
* [Import & Export](https://django-fast-Treenode.readthedocs.io/import_export/)
|
126
|
+
* [Caching and working with cache](https://django-fast-Treenode.readthedocs.io/cache/)
|
127
|
+
* [Migration and upgrade guide](https://django-fast-Treenode.readthedocs.io/migration/)
|
129
128
|
|
130
129
|
Your wishes, objections, comments are welcome.
|
131
130
|
|
132
131
|
## License
|
133
|
-
Released under [MIT License](https://github.com/TimurKady/django-fast-
|
132
|
+
Released under [MIT License](https://github.com/TimurKady/django-fast-Treenode/blob/main/LICENSE).
|
134
133
|
|
135
134
|
## Credits
|
136
135
|
Thanks to everyone who contributed to the development and testing of this package, as well as the Django community for their inspiration and support.
|
{django_fast_treenode-3.0.2 → django_fast_treenode-3.0.4/django_fast_treenode.egg-info}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: django-fast-treenode
|
3
|
-
Version: 3.0.
|
3
|
+
Version: 3.0.4
|
4
4
|
Summary: Treenode Framework for supporting tree (hierarchical) data structure in Django projects
|
5
5
|
Home-page: https://django-fast-treenode.readthedocs.io/
|
6
6
|
Author: Timur Kady
|
@@ -53,7 +53,7 @@ Classifier: Operating System :: OS Independent
|
|
53
53
|
Requires-Python: >=3.9
|
54
54
|
Description-Content-Type: text/markdown
|
55
55
|
License-File: LICENSE
|
56
|
-
Requires-Dist: Django>=
|
56
|
+
Requires-Dist: Django>=5.0
|
57
57
|
Requires-Dist: msgpack>=1.0.0
|
58
58
|
Requires-Dist: openpyxl>=3.0.0
|
59
59
|
Requires-Dist: pyyaml>=5.1
|
@@ -62,16 +62,16 @@ Dynamic: home-page
|
|
62
62
|
Dynamic: license-file
|
63
63
|
Dynamic: requires-python
|
64
64
|
|
65
|
-
#
|
65
|
+
# Treenode Framework
|
66
66
|
**A hybrid open-source framework for working with trees in Django**
|
67
67
|
|
68
68
|
[](https://github.com/TimurKady/django-fast-treenode/actions/workflows/test.yaml)
|
69
69
|
[](https://django-fast-treenode.readthedocs.io/)
|
70
|
-
[](https://pypi.org/project/django-fast-
|
70
|
+
[](https://pypi.org/project/django-fast-Treenode/)
|
71
71
|
[](https://djangopackages.org/packages/p/django-fast-treenode/)
|
72
72
|
[](https://github.com/sponsors/TimurKady)
|
73
73
|
|
74
|
-
## About The
|
74
|
+
## About The Treenode Framework
|
75
75
|
### Overview
|
76
76
|
|
77
77
|
**Treenode Framework** is an advanced tree management system for Django applications.It is designed to handle large-scale, deeply nested, and highly dynamic tree structures while maintaining excellent performance, data integrity, and ease of use.
|
@@ -87,7 +87,7 @@ Its core philosophy: **maximum scalability, minimum complexity**.
|
|
87
87
|
|
88
88
|
### Key Features
|
89
89
|
#### Common operations
|
90
|
-
The `django-fast-
|
90
|
+
The `django-fast-Treenode` package supports all the basic operations needed to work with tree structures:
|
91
91
|
|
92
92
|
- Extracting **ancestors** (queryset, list, pks, count);
|
93
93
|
- Extracting **children** (queryset, list, pks, count);
|
@@ -118,10 +118,10 @@ Typical applications include:
|
|
118
118
|
|
119
119
|
In all these domains, scalable and fast tree management is not a luxury — it's a necessity.
|
120
120
|
|
121
|
-
### Why
|
121
|
+
### Why Treenode Framework?
|
122
122
|
At the moment, django-fast-treeenode is, if not the best, then one of the best packages for working with tree data under Djangjo.
|
123
123
|
|
124
|
-
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-
|
124
|
+
- **High performance**: [tests show](docs/about.md#benchmark-tests) that on trees of 5k-10k nodes with a nesting depth of 500-600 levels, **Treenode Framework** (`django-fast-Treenode`) shows **performance 4-7 times better** than the main popular packages.
|
125
125
|
- **Flexible API**: today contains the widest set of methods for working with a tree in comparison with other packages.
|
126
126
|
- **Convenient administration**: the admin panel interface was developed taking into account the experience of using other packages. It provides convenience and intuitiveness with ease of programming.
|
127
127
|
- **Scalability**: **Treenode Framework** suitable for solving simple problems such as menus, directories, parsing arithmetic expressions, as well as complex problems such as program optimization, image layout, multi-step decision making problems, or machine learning..
|
@@ -134,7 +134,7 @@ To get started quickly, you need to follow these steps:
|
|
134
134
|
|
135
135
|
- Simply install the package via `pip`:
|
136
136
|
```sh
|
137
|
-
pip install django-fast-
|
137
|
+
pip install django-fast-Treenode
|
138
138
|
```
|
139
139
|
- Once installed, add `'treenode'` to your `INSTALLED_APPS` in **settings.py**:
|
140
140
|
```python {title="settings.py"}
|
@@ -147,9 +147,9 @@ To get started quickly, you need to follow these steps:
|
|
147
147
|
|
148
148
|
- Open **models.py** and create your own tree class:
|
149
149
|
```
|
150
|
-
from
|
150
|
+
from Treenode.models import TreenodeModel
|
151
151
|
|
152
|
-
class MyTree(
|
152
|
+
class MyTree(TreenodeModel):
|
153
153
|
name = models.CharField(max_length=255)
|
154
154
|
display_field = "name"
|
155
155
|
```
|
@@ -157,11 +157,11 @@ To get started quickly, you need to follow these steps:
|
|
157
157
|
- Open **admin.py** and create a model for the admin panel
|
158
158
|
```
|
159
159
|
from django.contrib import admin
|
160
|
-
from
|
161
|
-
from .models import
|
160
|
+
from Treenode.admin import TreenodeModelAdmin
|
161
|
+
from .models import MyTree
|
162
162
|
|
163
|
-
@admin.register(
|
164
|
-
class
|
163
|
+
@admin.register(MyTree)
|
164
|
+
class MyTreeAdmin(TreenodeModelAdmin):
|
165
165
|
list_display = ("name",)
|
166
166
|
search_fields = ("name",)
|
167
167
|
```
|
@@ -176,25 +176,24 @@ To get started quickly, you need to follow these steps:
|
|
176
176
|
```sh
|
177
177
|
python manage.py runserver
|
178
178
|
```
|
179
|
-
|
180
179
|
Everything is ready, enjoy 🎉!
|
181
180
|
|
182
181
|
## Documentation
|
183
|
-
Full documentation is available at **[ReadTheDocs](https://django-fast-
|
182
|
+
Full documentation is available at **[ReadTheDocs](https://django-fast-Treenode.readthedocs.io/)**.
|
184
183
|
|
185
184
|
Quick access links:
|
186
|
-
* [Installation, configuration and fine tuning](https://django-fast-
|
187
|
-
* [Model Inheritance and Extensions](https://django-fast-
|
188
|
-
* [Working with Admin Classes](https://django-fast-
|
189
|
-
* [API Reference](https://django-fast-
|
190
|
-
* [Import & Export](https://django-fast-
|
191
|
-
* [Caching and working with cache](https://django-fast-
|
192
|
-
* [Migration and upgrade guide](https://django-fast-
|
185
|
+
* [Installation, configuration and fine tuning](https://django-fast-Treenode.readthedocs.io/installation/)
|
186
|
+
* [Model Inheritance and Extensions](https://django-fast-Treenode.readthedocs.io/models/)
|
187
|
+
* [Working with Admin Classes](https://django-fast-Treenode.readthedocs.io/admin/)
|
188
|
+
* [API Reference](https://django-fast-Treenode.readthedocs.io/api/)
|
189
|
+
* [Import & Export](https://django-fast-Treenode.readthedocs.io/import_export/)
|
190
|
+
* [Caching and working with cache](https://django-fast-Treenode.readthedocs.io/cache/)
|
191
|
+
* [Migration and upgrade guide](https://django-fast-Treenode.readthedocs.io/migration/)
|
193
192
|
|
194
193
|
Your wishes, objections, comments are welcome.
|
195
194
|
|
196
195
|
## License
|
197
|
-
Released under [MIT License](https://github.com/TimurKady/django-fast-
|
196
|
+
Released under [MIT License](https://github.com/TimurKady/django-fast-Treenode/blob/main/LICENSE).
|
198
197
|
|
199
198
|
## Credits
|
200
199
|
Thanks to everyone who contributed to the development and testing of this package, as well as the Django community for their inspiration and support.
|
@@ -194,7 +194,7 @@ All results were normalized relative to the best observed values. Lower values i
|
|
194
194
|
| Children | 🥇1,0 | 1,1 | 1,4 | 🥉1,0 | 🥈1,0 | 1,6 |
|
195
195
|
| Siblings | 🥇1,0 | 1,1 | 2,8 | 1,1 | 🥈1,0 | 1,1 |
|
196
196
|
| Family | 314,2 | 10.110,0 | 🥈236,2 | 🥉273,4 | 609,9 | 🥇1,0 |
|
197
|
-
| Re-reading | 338,4 | 8.416,7 | 🥉445,7 | 727,4 | 🥇1,0 |
|
197
|
+
| Re-reading | 338,4 | 8.416,7 | 🥉445,7 | 727,4 | 🥇1,0 | 🥈1,3 |
|
198
198
|
| Random | 253,8 | 1,1 | 274,5 | 🥇1,0 | 🥈1,0 | 🥉1,3 |
|
199
199
|
| Move | 🥇1,0 | 23,75 | 🥈1,6 | 🥈1,3 | 268,2 | 7,5 |
|
200
200
|
| Delete | 42,8 | 🥈3,63 | 🥈1,9 | 4,7 | 27,6 | 🥇1,0 |
|
@@ -73,10 +73,10 @@ To get started quickly, you need to follow these steps:
|
|
73
73
|
```
|
74
74
|
from django.contrib import admin
|
75
75
|
from treenode.admin import TreeNodeModelAdmin
|
76
|
-
from .models import
|
76
|
+
from .models import MyTree
|
77
77
|
|
78
|
-
@admin.register(
|
79
|
-
class
|
78
|
+
@admin.register(MyTree)
|
79
|
+
class MyTreeAdmin(TreeNodeModelAdmin):
|
80
80
|
list_display = ("name",)
|
81
81
|
search_fields = ("name",)
|
82
82
|
```
|
@@ -178,7 +178,7 @@ def export_tree(node):
|
|
178
178
|
children = node.get_children()
|
179
179
|
return {
|
180
180
|
"id": node.id,
|
181
|
-
"
|
181
|
+
"parent": node.get_parent().id if node.get_parent() else None,
|
182
182
|
"name": node.name,
|
183
183
|
# Continue the list by inserting the required model fields
|
184
184
|
# Do not export the `children` field
|
@@ -192,7 +192,7 @@ with open("tree_data.json", "w") as f:
|
|
192
192
|
json.dump(data, f, indent=4)
|
193
193
|
```
|
194
194
|
|
195
|
-
This code exports your structure to `tree_data.json` file. JSON preserves the id →
|
195
|
+
This code exports your structure to `tree_data.json` file. JSON preserves the id → parent relationship, but without children.
|
196
196
|
|
197
197
|
Now clear the table:
|
198
198
|
```python
|
@@ -229,9 +229,9 @@ class Category(TreeNodeModel):
|
|
229
229
|
```
|
230
230
|
Be sure to add `treenode_display_field` as `django-fast-treenode` uses it to display nodes in the admin panel.
|
231
231
|
|
232
|
-
The `treenode_sort_field` attribute specifies the tree sorting order. The default value of this field is `None`. It will sort by the internal field `
|
232
|
+
The `treenode_sort_field` attribute specifies the tree sorting order. The default value of this field is `None`. It will sort by the internal field `priority`.
|
233
233
|
|
234
|
-
The `
|
234
|
+
The `priority` value will be generated automatically if not specified during import. It will either be set as nodes are inserted into the tree (in the order in which the nodes will appear in the imported data), or after they are inserted, depending on the results of sorting by the field specified in the `treenode_sort_field` attribute.
|
235
235
|
|
236
236
|
> Note: sorting functions are available for `django-tree-node` version 2.3 and higher.
|
237
237
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
## Roadmap
|
2
2
|
|
3
|
-
The **`django-fast-treenode`** package will continue to evolve from its original concept—combining the benefits of
|
3
|
+
The **`django-fast-treenode`** package will continue to evolve from its original concept—combining the benefits of hybrid models into a high-performance solution for managing and visualizing hierarchical data in Django projects.
|
4
4
|
|
5
5
|
The focus is on **speed, usability, and flexibility**.
|
6
6
|
|
@@ -8,36 +8,36 @@ The focus is on **speed, usability, and flexibility**.
|
|
8
8
|
|
9
9
|
The 3.x release series will focus on strengthening TreeNode Framework in terms of security, usability, and performance scalability, while maintaining backward compatibility and architectural cleanliness.
|
10
10
|
|
11
|
+
* **Version 3.1 — Background Task Worker (Production Mode)**
|
11
12
|
|
12
|
-
|
13
|
+
- Introduce a centralized queue manager with a multiprocessing or Redis-based backend.
|
14
|
+
- Add a built-in worker process for safe and efficient task execution in production environments.
|
15
|
+
- Provide a fallback auto-run mode for DEBUG environments (using `atexit` or thread-based handler).
|
16
|
+
- Ensure task queue consistency across multiple WSGI workers or scripts.
|
17
|
+
|
18
|
+
* **Version 3.2 — JWT Authentication for API**
|
13
19
|
|
14
20
|
- Introduce optional JWT-based token authentication for the auto-generated API.
|
15
21
|
- Allow easy activation through a single setting (`TREENODE_API_USE_JWT = True`).
|
16
22
|
- Preserve backward compatibility: API remains open unless explicitly protected.
|
17
23
|
- Foundation for future security features (e.g., user-specific trees, audit trails).
|
18
24
|
|
19
|
-
* **Version 3.
|
25
|
+
* **Version 3.3 — Admin Usability Improvements**
|
20
26
|
|
21
27
|
Focus: enhance operational safety and optimize workflows for large-scale trees.
|
22
28
|
|
23
|
-
- **Safe Import Preview**:
|
24
|
-
|
25
|
-
Implement a staging layer for imports, allowing users to review and confirm imported data before committing changes.
|
26
|
-
|
27
|
-
- **Incremental Export**:
|
29
|
+
- **Safe Import Preview**: Implement a staging layer for imports, allowing users to review and confirm imported data before committing changes.
|
30
|
+
- **Incremental Export**: Support selective export of nodes modified after a specified date or revision marker.
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
* **Version 3.3 — Soft Deletion Support**
|
32
|
+
* **Version 3.4 — Soft Deletion Support**
|
33
33
|
|
34
34
|
Focus: improve real-world resilience without sacrificing performance.
|
35
35
|
|
36
36
|
- Add optional support for "soft delete" behavior (`is_deleted` field).
|
37
37
|
- Modify core queries and cache invalidation logic to respect soft-deleted nodes.
|
38
38
|
- Add a new task type to the internal task queue system for bulk logical deletions.
|
39
|
-
|
40
|
-
* **Version 3.
|
39
|
+
|
40
|
+
* **Version 3.5 — Cache System Enhancements**
|
41
41
|
|
42
42
|
Focus: lay the foundation for scaling Treenode Framework to extreme node counts (>100,000 nodes).
|
43
43
|
|
@@ -49,13 +49,12 @@ Each step in the 3.x roadmap is intended to strengthen the framework's key princ
|
|
49
49
|
|
50
50
|
#### Long-Term Vision
|
51
51
|
|
52
|
+
* **Version 4.0 – Improved Architecture**
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
The main debut idea of version 4.0 is to further develop the hybrid approach. This version will implement a new new architectural solution that is designed to increase the speed of selecting descendants, and therefore moving subtrees, and remove the existing restrictions on the maximum nesting depth of the tree (currently the recommended value when using up to 1000 levels).
|
54
|
+
The main debut idea of version 4.0 is to further develop the hybrid approach. This version will implement a new architectural solution that is designed to increase the speed of selecting descendants, and therefore moving subtrees, and remove the existing restrictions on the maximum nesting depth of the tree (currently the recommended value when using up to 1000 levels).
|
56
55
|
|
57
|
-
- Speed
|
58
|
-
-
|
56
|
+
- Speed up the operation of extracting descendants.
|
57
|
+
- Speed up operations for moving large subtrees.
|
59
58
|
- Performance optimization when working with trees that have extreme depth (more than 2000 levels).
|
60
59
|
|
61
60
|
* **Version 5.0 – Beyond Django ORM**
|
@@ -71,4 +70,4 @@ So, each milestone is designed to improve performance, scalability, and flexibil
|
|
71
70
|
|
72
71
|
Stay tuned for updates!
|
73
72
|
|
74
|
-
Your wishes, objections, and comments are welcome.
|
73
|
+
Your wishes, objections, and comments are welcome.
|
@@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "django-fast-treenode"
|
7
|
-
version = "3.0.
|
7
|
+
version = "3.0.4"
|
8
8
|
description = "Treenode Framework for supporting tree (hierarchical) data structure in Django projects"
|
9
9
|
readme = "README.md"
|
10
10
|
authors = [{ name = "Timur Kady", email = "timurkady@yandex.com" }]
|
11
11
|
license = { file = "LICENSE" }
|
12
12
|
requires-python = ">=3.9"
|
13
13
|
dependencies = [
|
14
|
-
'Django>=
|
14
|
+
'Django>=5.0',
|
15
15
|
'msgpack>=1.0.0',
|
16
16
|
'openpyxl>=3.0.0',
|
17
17
|
'pyyaml>=5.1',
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='django-fast-treenode',
|
5
|
-
version='3.0.
|
5
|
+
version='3.0.4',
|
6
6
|
description='Treenode Framework for supporting tree (hierarchical) data structure in Django projects',
|
7
7
|
long_description=open('README.md', encoding='utf-8').read(),
|
8
8
|
long_description_content_type='text/markdown',
|
@@ -14,7 +14,7 @@ setup(
|
|
14
14
|
license='MIT',
|
15
15
|
license_files=['LICENSE'],
|
16
16
|
install_requires=[
|
17
|
-
'Django>=
|
17
|
+
'Django>=5.0',
|
18
18
|
'msgpack>=1.0.0',
|
19
19
|
'openpyxl>=3.0.0',
|
20
20
|
'pyyaml>=5.1',
|
@@ -84,7 +84,7 @@ class AdminMixin(admin.ModelAdmin):
|
|
84
84
|
value = field(obj)
|
85
85
|
field_name = getattr(field, "__name__", "field")
|
86
86
|
else:
|
87
|
-
attr, value = lookup_field(field, obj, self)
|
87
|
+
r, attr, value = lookup_field(field, obj, self)
|
88
88
|
field_name = field
|
89
89
|
|
90
90
|
row_data.append(value)
|
@@ -5,13 +5,14 @@ Low-level SQL Query Manager.
|
|
5
5
|
Encapsulates all logic to retrieve related primary keys based on relationships
|
6
6
|
(e.g., ancestors, children, descendants, siblings, family, root) using raw SQL.
|
7
7
|
|
8
|
-
Version: 3.0.
|
8
|
+
Version: 3.0.4
|
9
9
|
Author: Timur Kady
|
10
10
|
Email: timurkady@yandex.com
|
11
11
|
"""
|
12
12
|
|
13
13
|
|
14
14
|
from django.db import connection
|
15
|
+
from ..utils.db.sqlcompat import SQLCompat
|
15
16
|
|
16
17
|
|
17
18
|
class TreeQuery:
|
@@ -32,19 +33,6 @@ class TreeQuery:
|
|
32
33
|
cursor.execute(sql, params)
|
33
34
|
return cursor.fetchall()
|
34
35
|
|
35
|
-
def wrap_union_all(self, queries):
|
36
|
-
"""
|
37
|
-
Combine multiple SQL queries using UNION ALL.
|
38
|
-
|
39
|
-
Each query is a tuple: (sql, params).
|
40
|
-
Returns a tuple: (combined_sql, combined_params).
|
41
|
-
"""
|
42
|
-
union_query = " UNION ALL ".join(f"({q[0]})" for q in queries)
|
43
|
-
combined_params = []
|
44
|
-
for q in queries:
|
45
|
-
combined_params.extend(q[1])
|
46
|
-
return union_query, combined_params
|
47
|
-
|
48
36
|
def order_by(self, sql, order_by_clause):
|
49
37
|
"""Wrap the SQL in an outer query to enforce ordering."""
|
50
38
|
return f"SELECT * FROM ({sql}) AS combined ORDER BY {order_by_clause}"
|
@@ -76,7 +64,7 @@ class TreeQuery:
|
|
76
64
|
if include_self:
|
77
65
|
sql2 = f"SELECT id, priority FROM {self.db_table} WHERE id = %s"
|
78
66
|
params2 = [self.node.pk]
|
79
|
-
combined_sql, combined_params =
|
67
|
+
combined_sql, combined_params = SQLCompat.wrap_union_all(
|
80
68
|
[(sql1, params1), (sql2, params2)])
|
81
69
|
sql = self.order_by(combined_sql, "priority")
|
82
70
|
return sql, combined_params
|
@@ -115,7 +103,7 @@ class TreeQuery:
|
|
115
103
|
FROM {self.db_table}
|
116
104
|
WHERE id = %s
|
117
105
|
"""
|
118
|
-
union_sql, union_params =
|
106
|
+
union_sql, union_params = SQLCompat.wrap_union_all([
|
119
107
|
(base_sql, params),
|
120
108
|
(sql_self, [self.node.pk])
|
121
109
|
])
|
@@ -148,7 +136,7 @@ class TreeQuery:
|
|
148
136
|
|
149
137
|
if include_self:
|
150
138
|
sql_self = f"SELECT id, _depth, priority FROM {self.db_table} WHERE id = %s" # noqa: D501
|
151
|
-
union_sql, union_params =
|
139
|
+
union_sql, union_params = SQLCompat.wrap_union_all(
|
152
140
|
[(base_sql, params), (sql_self, [self.node.pk])])
|
153
141
|
else:
|
154
142
|
union_sql, union_params = base_sql, params
|
@@ -198,7 +186,7 @@ class TreeQuery:
|
|
198
186
|
if include_self:
|
199
187
|
sql_self = f"SELECT id, _depth, priority FROM {self.db_table} WHERE id = %s" # noqa: D501
|
200
188
|
queries.append((sql_self, [self.node.pk]))
|
201
|
-
combined_sql, combined_params =
|
189
|
+
combined_sql, combined_params = SQLCompat.wrap_union_all(queries)
|
202
190
|
combined_sql = self.order_by(combined_sql, "_depth, priority")
|
203
191
|
return combined_sql, combined_params
|
204
192
|
|