Quantcast
Channel: for loop with an integer in django's templates tags - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Joseph Rajchwald for for loop with an integer in django's templates tags

$
0
0

You can pass the range from the view to the template and then loop through that. Referencing this SO answer:

View:

render_to_response('template.html', {..., 'stars': range(review.stars), ...}, ...)

Template:

{% for n in stars %}    # add star icon{% endfor %}

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>