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
  • 298,606
  • 55
  • 578
  • 516
Vladyslav
  • 2,018
  • 4
  • 18
  • 44

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
  • 10,713
  • 1
  • 52
  • 62