N
N
nurzhannogerbek2017-12-20 21:54:06
Oracle
nurzhannogerbek, 2017-12-20 21:54:06

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.
5a3aac45b4e8e807551449.png
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.
5a3aae4e99dc6916345736.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2017-12-20
@nurzhannogerbek

Have a look here: django-mptt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question