So I am generating a folder structure that uses accordion from bootstrap. This is working as intended for 1 level of depth. As soon as I want to go into 2+ levels of depth it does not work as intended.
I get it working by tricking the handler.
I run this via docker containers. I have a main for loop in the root of the structure. I that calls a template. I keep this template in partials folder. This works fine. within this template that is in the partials folder I once again call the template file as it should be a recursive loop until there is no need to call it again.
I start my server using the following within the template: {% include "partials/subfolder_template.django" with folder=folder %} This holds the server from starting but I quickly modify this line to this: {% include "subfolder_template.django" with folder=folder %} Removing the partials/ makes the server work and boom - This server now starts and when I go to my handler the depth levels work as intended.
The issue with this is that if the container fails or gets restarted then this will fail and show the following error on the page: failed to render: template department/media_view does not exist
department/media_view template:
<main class="mb-auto container-fluid w-100 h-100 text-center pt-3">
{% for folder in Folders.Subfolders %}
<div id="accordion-2" role="tablist" aria-multiselectable="true" class="o-accordion">
<div class="card multi">
<div class="card-header" role="tab" id="heading{{folder.Name}}">
<h5 class="mb-0">
<a class="r2_image_link collapsed" data-toggle="collapse" style="text-transform: uppercase;" data-parent="#accordion" href="#collapse{{folder.Name}}" aria-expanded="false" aria-controls="collapse{{folder.Name}}">
<i class="fa-solid fa-folder" style="color: #e4b91b;"></i> {{folder.Name}}
</a>
</h5>
</div>
<div id="collapse{{folder.Name}}" class="collapse" role="tabpanel" aria-labelledby="heading{{folder.Name}}">
<div class="card-block">
{% if folder.Subfolders %}
<div class="container-fluid w-100 h-100 text-center pt-3">
<ul>
{% include "partials/subfolder_template.django" with folder=folder %}
</ul>
</div>
{% endif %}
<ul>
{% for image in folder.Images %}
<div class="container-fluid w-100 h-100 text-center pt-3">
<div class="d-flex justify-content-between align-items-center" style="padding-bottom: 10px; padding-top: 10px; border-bottom: 1px solid rgb(104, 104, 104);">
<img width="100px" src="https://{{Domain}}/{{image.URL}}" alt="">
<a class="r2_image_link copy-text" data-alt="https://{{Domain}}/{{image.URL}}">
<p style="padding-left: 30px;">{{image.Name}}</p>
</a>
</div>
</div>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endfor %}
</main>
partials/subfolder_template.django template:
{% for folder in folder.Subfolders %}
<div class="container-fluid w-100 h-100 text-center pt-3">
<div class="card multi">
<div class="card-header" role="tab" id="heading{{folder.Name}}/">
<h5 class="mb-0">
<a class="r2_image_link collapsed" data-toggle="collapse" data-parent="#accordion" style="text-transform: uppercase;" href="#collapse{{folder.Name}}/" aria-expanded="false" aria-controls="collapse{{folder.Name}}/">
<i class="fa-solid fa-folder" style="color: #e4b91b;"></i> {{folder.Name}}
</a>
</h5>
</div>
<div id="collapse{{folder.Name}}/" class="collapse" role="tabpanel" aria-labelledby="heading{{folder.Name}}/">
<div class="card-block">
<ul class="collapsible-list">
{% for image in folder.Images %}
<div class="d-flex justify-content-between align-items-center" style="padding-bottom: 10px; padding-top: 10px; border-bottom: 1px solid rgb(104, 104, 104);">
<img width="50px" src="https://{{Domain}}/{{image.URL}}">
<a class="r2_image_link copy-text" data-alt="https://{{Domain}}/{{image.URL}}">
<p style="padding-left: 30px;">{{folder.Name}}</p>
</a>
</div>
{% endfor %}
{% if folder.Subfolders %}
<div class="container-fluid w-100 h-100 text-center pt-3">
<ul>
{% include "partials/subfolder_template.django" with folder=folder %}
</ul>
</div>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
{% endfor %}
The workaround goes like this:
- Run docker compose up with templates as above.
- Server will stall, quickly remove the
{% include "partials/subfolder_template.django" with folder=folder %}
line within the partials/subfolder_template.django file. - Server will boot up with no issues. Recursion will work to the nth level.
If I now reboot the container It will only server 2 layers of recursion depth.
The workaround goes like this:
Run docker compose up with templates as above.
Server will stall, quickly remove the {% include "partials/subfolder_template.django" with folder=folder %} line within the partials/subfolder_template.django file.
Server will boot up with no issues. Recursion will work to the nth level.
If I now reboot the container It will only server 2 layers of recursion depth.