【发布时间】:2019-07-10 06:44:20
【问题描述】:
我在divs 中创建了一个循环。第一个 div 用于第一列,另一个 div 用于第二列。我只希望它在views.py 中管理。我在views.py 中为两个单独的divs 创建了两个函数。但它没有向我显示最后一个函数的结果。它只是向我展示了第一个功能图片,并且只有第一个 div 正在工作。
index.html
{% static 'images/fulls' as baseUrl %}
{% static 'images/thumbs' as hiUrl %}
<div class="row">
{% for dest in dest1 %}
<div class="col-lg-4">
<a href="{{baseUrl}}/{{dest.img}}">
<img src="{{hiUrl}}/{{dest.img}}" alt="" />
<h3>{{destt.desc}}</h3>
</a>
</div>
{%endfor%}
</div>
{% for destt in dest2 %}
<div>
<a href="{{baseUrl}}/{{destt.img}}">
<img src="{{hiUrl}}/{{destt.img}}" alt="" />
<h3>{{destt.desc}}</h3>
</a>
</div>
{% endfor %}
views.py
def index(request):
dest1 = Destination()
dest1.desc = 'Hello, How arE you?'
dest1.img = '01.jpg'
return render(request, 'index.html', {'dest1':dest1})
def nextt(request):
dest2 = Destination()
dest2.desc = 'Hello, How arE you?'
dest2.img = '02.jpg'
return render(request, 'index.html', {'dest2':dest2})
【问题讨论】: