Closed amaury1093 closed 5 years ago
With this demo you don't construct the path "by hand" but let PostgreSQL construct it for you, only based on who the parent is. So you actually need to store the parent's ID in order to let the DB do its stuff :) .
If you don't mind managing the path by yourself then, indeed, you don't need to store the parent. You also don't need the SQL triggers.
Got it, thanks!
https://github.com/peopledoc/django-ltree-demo/blob/575225237977c010e19bb1f33a5dd764c7183946/demo/categories/models.py#L7-L8
Am i correct in saying that this field is not actually needed, since with a materialized path you already have the whole path to the root? It's just convenience field for to get each node's parent/children?