Answer the question
In order to leave comments, you need to log in
How to create a tree structure in Django?
Hello! Please help me figure it out.
I'm trying to create a tree with a list of documents with the ability to drag and drop them, as in the figure.
I use Oracle DBMS in my Django project. To create such a tree-like list, it is necessary to store data in a hierarchical form. Would it be correct to use the "Closure Table" design pattern? I want to know your opinion on how to properly design a data model in Django.
In "Close Table" in theory there should be two tables. One contains information about the document. The second table specifies descendants (descendent), ancestors (ancestor) and nesting level (level). When dragging documents, the location changes, so I think to use the position field. I can't figure out what the data model for the Documents table should look like. Should there be some kind of foreign key and how to compose a QuerySet with similar tables (for example, display a list of documents in a hierarchical order)? As you can see, there are many questions, I would like to know your opinion about a similar task.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question