can i add a {% for in %} loop and {{ variables }} in django template using javascript dom (insertAdjacentText, or textContent) and charge data from the views something like refresh only the part of html that containt the added for loop or refresh the page without loosing the javascript execution ? if yes guide me i searched and i did not
function displayMaquette(){
let label = document.getElementById('label');
let rem = document.getElementById('remove')
let amg = document.getElementsByClassName('amg')
let namep =document.getElementsByClassName('namep')
let add =document.getElementById('add')
add.insertAdjacentText('afterbegin','{% for plan in plan3 %}')
add.insertAdjacentText('beforeend','{% endfor %}')*/
for(let i =0;i<x.length;i++){
x[i].textContent='{{ plan.IdPlans }}'
amg[i].setAttribute('src','{{plan.Image.url}}')
namep[i].textContent='{{ plan.NamePlan }} :'
}
}
<figure id="label3" class="fig" onclick="displayMaquette()">
<figcaption class="caption" onmouseover="figCaptionHover(this)" onmouseout="figCaptionOut(this)">Cliquez pour afficher les maquettes</figcaption>
<img class="figimg" src="" alt="Elephant at sunset" >
</figure>
</div>
<article class="works none">
<p class="pNone" style="display: none;"></p>
<div class="worksimg">
<img class="Img amg" Img src="">
</div>
<div class="Description">
<h2 class="namep"></h2>
<p></p>
</div>
</article>
<div id="remove"></div>
find? By onclick event i add the for loop and {{ variables }} but it display as text in the browser it doesn't charge datas from views what i wan't is charge data from database