D
D
Dmitry2015-04-12 11:12:09
Django
Dmitry, 2015-04-12 11:12:09

How to implement hierarchical data storage in django?

Actually interested in implementation methods, best practices on how to store and output data with a hierarchical structure, for example, categories of unlimited nesting.
PS: django1.7-1.8 python3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-04-12
@sim3x

https://www.djangopackages.com/grids/g/tree-traversal/

N
Novel, 2015-04-16
@skipirich

Insert the parent_id field into the categories table. Where parent_id is the ID of the parent category. Then, using recursion, assemble the desired structure, of course, to visually build the list, you will have to shove html tags into the code, for example, ul li. I think 50 lines can be kept within.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question