2

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?

Community
  • 1
  • 1
gatlanticus
  • 1,158
  • 2
  • 14
  • 28

0 Answers0