0
我想在我的頭文件中顯示我最新的文章,並讓for循環中的其他文章偏移一個,所以在我的頭文件中沒有相同的文章,另一個我所有的其他職位。我如何在一個Django模板中循環偏移
在我的views.py我有
latest = Post.objects.latest('id')
context = {
......
"latest": latest
}
在我list.html
<div class="jumbotron col-sm-12">
<div class="container">
<div class="row">
<p>{{latest}}</p>
<div class="col-sm-8">
<img src='{{ latest.image.url }}' class="img-responsive"/>
</div>
<div class="col-sm-4 pull-right" style="background-color: #212121; height: 300px">
</div>
</div>
</div>
</div>
和
{% for q in object_list %}
{{ q.title }}
{% endfor %}
我怎麼彌補我的for循環1
感謝您的所有方法我將使用最後一個謝謝 – losee
很高興爲您提供幫助。如果有效,請接受答案。 – AKS