Answer the question
In order to leave comments, you need to log in
How to use Django data in external JS script?
Hello, in general, the situation is this, through views I pass data from the database to index.html in this format
<div class="image-floor">
<h3>Этаж <span class="num-floor">01</span></h3>
<svg width="433" height="408" viewBox="0 0 433 408" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<image id="image0" width="433" height="408" xlink:href="{% static 'img/flats.png' %}"></image>
<path id="p0" class="flats-path" d="M46.5 81V115.5H125V144.5H164V131H184.5V32.5H93V16H28V81H46.5Z" fill="#3595F6" fill-opacity="0.75"></path>
.......
</svg>
</div>
document.querySelector(".num-floor").textContent = counter.textContent
<div>
{% for i in flats %}
<h6>{{ i.id }}, {{ i.price }}, {{ i.reserved }}</h6>
{% endfor %}
</div>
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