Django多活动项目转盘

Django多活动项目转盘,django,carousel,Django,Carousel,我正在从数据库中提取产品,并尝试在屏幕上的多个旋转框/项目中显示它们,而不是使用for循环的单个项目 这就是我的旋转木马目前的样子,因为您会注意到只显示一个项目,但我希望它在一张幻灯片上显示4个项目,然后单击箭头按钮显示四个项目,依此类推。 我的Django代码如下所示-- {pro%中prod的%s} {{prod.productname} {{prod.producttype} {%endfor%} 尝试这样做: <div id="recommended-item-carousel

我正在从数据库中提取产品,并尝试在屏幕上的多个旋转框/项目中显示它们,而不是使用for循环的单个项目

这就是我的旋转木马目前的样子,因为您会注意到只显示一个项目,但我希望它在一张幻灯片上显示4个项目,然后单击箭头按钮显示四个项目,依此类推。 我的Django代码如下所示--


{pro%中prod的%s}
{{prod.productname}
{{prod.producttype}

{%endfor%}
尝试这样做:

<div id="recommended-item-carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">         
    <div class="item active">
    {% for prod in pro %}
        <div class="col-sm-3">
            <div class="product-image-wrapper1">
                <div class="single-products">
                    <div class="productinfo text-center">
                        <!--sample image, same for all--><img src="{% static 'header/images/home/2508__14291.1437672247.200.200.jpg' %}" alt="" />
                        <h2>{{prod.productname}}</h2>
                        <p>{{prod.producttype}}</p>
                        <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                    </div>
                </div>
            </div>
        </div>
       {% if forloop.counter|divisibleby:4 and not forloop.last %}
       </div>
       <div class="item">
       {% endif %}
    {% endfor %}
    </div>  
</div>
<a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev">
<i class="fa fa-angle-left"></i>
</a>
<a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next">
<i class="fa fa-angle-right"></i>
</a>            

{pro%中prod的%s}
{{prod.productname}
{{prod.producttype}

{%if-forloop.counter |可除数为:4而非forloop.last%} {%endif%} {%endfor%}