Django-tree

Latest version: v0.5.6

Safety actively analyzes 623395 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.5.6

==================

- Adds a model validation in addition to the existing database error,
when users try to make a cycle (mark a node as its own parent or ancestor)
- Moves ``PathField.get_roots()`` to ``TreeQuerySetMixin.filter_roots()``.
- Fixes a ``TypeError`` when using ``TreeQuerySetMixin.get_descendants()``
on an empty queryset.

0.5.5

==================

Fixes another PostgreSQL 12 compatibility issue.

0.5.4

==================

Fixes an SQL syntax error.

0.5.3

==================

Fixes a PostgreSQL implicit type casting that was not done in PostgreSQL 12.

0.5.2

==================

Fixes a source of path clashes when the objects have exactly the same values
for all ``order_by`` columns.

0.5.1

==================

Big rewrite using arrays of decimals instead of strings to represent the path.

Performance
-----------

For more details, see the `benchmark results <benchmark/results/results.rst>`_.

- Inserting becomes orders of magnitude faster, often faster than django-treebeard and django-mptt.
- Updating becomes faster in all cases, especially when the instance stays at the same place where it becomes orders of magnitude faster.
- Deleting becomes most of the time orders of magnitude faster.
- Reading stays as fast as it was.

Upgrading
---------

- Add a new empty migration in each application that contains ``PathField``s.
- For each ``PathField`` defined in the application, add:
- ``DeleteTreeTrigger``
- ``RemoveField`` of the path field
- ``AddField`` of the path field
- ``CreateTreeTrigger``
- ``RebuildPaths``

For example:

.. code-block:: python

DeleteTreeTrigger('Place'),
migrations.RemoveField('Place', 'path'),
migrations.AddField(
model_name='Place',
name='path',
field=PathField(db_index=True, order_by=['name'], size=None),
),
CreateTreeTrigger('place'),
RebuildPaths('place'),

You can also comment the ``PathField`` in the model itself, run ``makemigrations``
to create a first migration with the ``RemoveField``, add the ``DeleteTreeTrigger`` before,
then uncomment the field in the model, run ``makemigrations`` to generate a second migration with the ``AddField``
in it, and finally add the ``CreateTreeTrigger`` and ``RebuildPaths`` at the end.

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.