Skip to content

Commit

Permalink
Refs #71: Add an example to the docs how to work around missing features
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Aug 19, 2024
1 parent 1bd324e commit 23fd3c5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ Basic usage
# Temporarily override the ordering by siblings.
nodes = Node.objects.order_siblings_by("id")
Note that the tree queryset doesn't support all types of queries Django
supports. For example, updating all descendants directly isn't supported:

.. code-block:: python
# Doesn't work
node.descendants().update(is_active=False)
The reason for that is that the recursive CTE isn't added to the UPDATE query
correctly. Workarounds often include moving the tree query into a subquery:

.. code-block:: python
Node.objects.filter(pk__in=node.descendants()).update(is_active=False)
Breadth-first search
--------------------
Expand Down

0 comments on commit 23fd3c5

Please sign in to comment.