Is there a way to do {% url 'blog' blog[i].slug %} in Django?

I want to make this type of loops: {% for i in length %}

where lenth = range(len(blogs)) in views.py. And then into that loop I want to do: <a href="{% url 'single_blog' blogs[i].slug %}"> blogs go from views.py too: blogs = Blog.objects.all()

But it shows an error, it says it can't use [i] in this construction. Please let me know, how can I use blogs[i] in Django HTML? Thanks.

Back to Top