Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question