This is my template code:
{% block content %}
{% get_latest as latest_posts %}
<ul>
{% for post in latest_posts %}
<li>
<p><a href="{{ post.get_absolute_url }}">{{ post.title|safe }}</a></p>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block sidebar %}
<ul>
{% for post in latest_posts %}
<li>
<p><a href="{{ post.get_absolute_url }}">{{ post.title|safe }}</a></p>
</li>
{% endfor %}
</ul>
{% endblock %}
In the content block the for loop does works, but in the sidebar block I can't use the variable latest_posts. Can anyone help me with this?