gatlanticus
gatlanticus

Reputation: 1226

Checking tree modifications in django-treebeard ORM before saving

I want to double-check if I am correctly interpreting the following section of the django-treebeard docs:

django-treebeard uses Django raw SQL queries for some write operations, and raw queries don’t update the objects in the ORM since it’s being bypassed.

Because of this, if you have a node in memory and plan to use it after a tree modification (adding/removing/moving nodes), you need to reload it.

Here's my understanding:

If I've loaded a node from the database and am working on it in memory, I must use refresh_from_db() before saving. Also, in case the tree is modified between refresh_from_db and save, I should wrap the two calls in an atomic transaction.

Is this correct?

Upvotes: 2

Views: 253

Answers (0)

Related Questions