0

I have some django application, i need to render some html with this block of code:

{% for i in review.mark|range %}
     img src="{% static 'core/img/star-yellow.svg' %}" alt="star">
{% endfor %}

Sometimes filter range help me with this (review.mark is only IntegerField in my model). I have mark from 1 to 5, and i want to loop for review.mark times. How can i do this in django templates?

Alasdair
  • 278,338
  • 51
  • 534
  • 489
Vladyslav
  • 1,832
  • 4
  • 17
  • 42

1 Answers1

0

we can do like below

{% load static %}
{% for _ in "x"|rjust:review.mark %}
  <img src="{% static 'core/img/star-yellow.svg' %}" alt="star" />
{% endfor %}
anjaneyulubatta505
  • 8,942
  • 1
  • 40
  • 56