Question:
How is the value of the path column under the wagtailcore_page table populated?

Problem:

I need to insert bulk pages in wagtail database and I need to find out how is the value of path column under wagtailcore_page table is decided?

I tried looking into the database but couldn't map the value of this path column to the path of the page.


Solution:

Wagtail uses the >Materialised path implementation from django-treebeard to represent the tree structure. The path string is a sequence of four-character elements - for example, "000000020001" can be read as "0000 0002 0001". For each level you go down the tree, you add a new element to that sequence - for example:

  • 0000 is the root node

  • 00000000 is the first child of the root

  • 00000001 is the second child of the root

  • 000000010000 is the first child of the second child of the root

  • 000000010001 is the second child of the second child of the root

Each page's path always begins with the path of its parent, so you can quickly find all children and descendants of the page with path 00000001 by looking for paths starting with 00000001.

Also, note that these strings are not just numeric - django-treebeard uses an alphanumeric alphabet, so 0009 would be followed by 000A, 000B, 000C... and 000Z is followed by 0010. (This ensures that you can have a lot more than 9999 children per parent.)


Suggested blogs:

>How to solve the issue of producing the wrong output value in PHP?

>How to solve XGBoost model training fails in Python

>How to Upload files and JSON data in the same request with Angular?

>How to Use RTK Queries in a React App?

>How you can create array with associative array in other array php?

>How you can send email from a shared inbox in Python

>How you can Show or hide elements in React?


Ritu Singh

Ritu Singh

Submit
0 Answers