Hello good, I have a problem using the for and for loop, what I want is that this process is repeated in all pages, so I put it in the base page.html. I want the last added in all pages like, in the blog, login and index. At this moment you can only see it in the index.
This is code inside the base:
<div>
<h3 class="blog-title">Latest Additions</h3>
{% for anime in num_blog %}
{% if forloop.revcounter %}
<a href="{% url 'anime-detail' anime.pk%}"> <img class="img-asides" src="{{ anime.image.url }}" alt=""></a>
<h3
style="text-align: center; max-width: 180px; font-size: 13px; margin-right: auto; margin-left: auto;">
{{ anime.tituloPag }}</h3>
{% endif %}
{% endfor %}
</div>
This is the code in views.py:
def index(request):
num_blog = Anime.objects.all()
return render(
request,
'index.html',
context={'num_blog':num_blog}
)
def blog(request):
num_blog = Anime.objects.all()
return render(
request,
'blog.html',
context={'num_blog':num_blog}
)
But as I said you can only see the loop inside the index.html and not in the other pages, what can I do?