0

I have a root folder, containing other folders and XML-files. I would like to show the folder contents just like in windows-explorer on my webpage. For example:

folder_1
    txt_file_1
    txt_file_2
folder_2 
    folder_3
        txt_file_3

How can I render the directory in this way?

TomatoFarmer
  • 463
  • 3
  • 13

1 Answers1

0

I had a similar use case that I was able to solve by recursively including a template.

In my main template I start the recursion: {% include "myapp/tree.html" with children=list_of_objects %}

In the tree.html file, the actual recursion occurs:

{% for child in children %}

{% include "myapp/tree.html" with children=list_of_objects %}

{% endfor %}

You would still need to return a list/dictionary of directories from your view (or possibly create a custom template tag to handle it).

Rekamanon
  • 217
  • 2
  • 10