Welcome to the Cookbook

loading...

6.4.1 Requirements

To use the tree behavior, your database table needs 3 fields as listed below (all are ints):

  • parent - default fieldname is parent_id, to store the id of the parent object
  • left - default fieldname is lft, to store the left value of the current row.
  • right - default fieldname is rght, to store the right value of the current row.

If you are familiar with MPTT logic you may wonder why a parent field exists - quite simply it's easier to do certain tasks if a direct parent link is stored on the database - such as finding direct children.