html - 如何在 django 模板中制作水平产品列表视图
问题描述
如何在 django 模板中制作水平产品列表视图
您可以在这里查看我的产品列表图片,
1:https ://i.stack.imgur.com/b6ZBH.png
视图.py
class ProductView(ListView):
model = Product
queryset = Product.objects.all()
fields = "__all__"
template_name = "demoapp/product.html"
产品.html:
{% for product in object_list %}
<div class='row'>
<div class="col-sm-6 col-md-4 col-lg-3 p-b-35 isotope-item men {{ col_class_set }}">
<!-- Block2 -->
<div class="block2">
<div class="block2-pic hov-img0">
<img src="{{ product.image.url }}" alt="IMG-PRODUCT">
<a href="#" class="block2-btn flex-c-m stext-103 cl2 size-102 bg0 bor2 hov-btn1 p-lr-15 trans-04 js-show-modal1">
Quick View
</a>
</div>
<div class="block2-txt flex-w flex-t p-t-14">
<div class="block2-txt-child1 flex-col-l ">
<a href="product-detail.html" class="stext-104 cl4 hov-cl1 trans-04 js-name-b2 p-b-6">
{{product.title}}
</a>
<span class="stext-105 cl3">
${{product.price}}
</span>
</div>
<div class="block2-txt-child2 flex-r p-t-3">
<a href="#" class="btn-addwish-b2 dis-block pos-relative js-addwish-b2">
<img class="icon-heart1 dis-block trans-04" src="images/icons/icon-heart-01.png" alt="ICON">
<img class="icon-heart2 dis-block trans-04 ab-t-l" src="{% static "images/icons/icon-heart-02.png" %}" alt="ICON">
</a>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
解决方案
尝试这个。
That is not achieve by django. Try changing in your html. just change your
<div class="col-sm-4> or <div class="col-sm-3> as per your requirements.
<div class='row'>
{% for product in object_list %}
<div class="col-sm-6 col-md-4 col-lg-3 p-b-35 isotope-item men {{ col_class_set }}">
<!-- Block2 -->
<div class="block2">
<div class="block2-pic hov-img0">
<img src="{{ product.image.url }}" alt="IMG-PRODUCT">
<a href="#" class="block2-btn flex-c-m stext-103 cl2 size-102 bg0 bor2 hov-btn1 p-lr-15 trans-04 js-show-modal1">
Quick View
</a>
</div>
<div class="block2-txt flex-w flex-t p-t-14">
<div class="block2-txt-child1 flex-col-l ">
<a href="product-detail.html" class="stext-104 cl4 hov-cl1 trans-04 js-name-b2 p-b-6">
{{product.title}}
</a>
<span class="stext-105 cl3">
${{product.price}}
</span>
</div>
<div class="block2-txt-child2 flex-r p-t-3">
<a href="#" class="btn-addwish-b2 dis-block pos-relative js-addwish-b2">
<img class="icon-heart1 dis-block trans-04" src="images/icons/icon-heart-01.png" alt="ICON">
<img class="icon-heart2 dis-block trans-04 ab-t-l" src="{% static "images/icons/icon-heart-02.png" %}" alt="ICON">
</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
推荐阅读
- html - *ngFor 生成的 mat-button 专注于加载
- uima - uima ruta 在一个 ruta 规则中创建两个注释
- android - 带有 customadapter 的 ListView -> onclick 对话框
- java - Main.isLeapYear 的结果被忽略 - 为什么?
- tensorflow - 构建 tensorflow 单元测试的问题
- sql - 如果有任何类似条件的值,请选择所有值
- c++ - 如何清除 Arduino 中串行接口的字节?
- python - 使用 python 3.x 进行网络抓取,我使用 pytharm
- c++ - 当 contentwidth 很大时,Flickable 中的 QQuickPaintedItem 变得模糊
- node.js - node.js ws:如何识别哪个websocket发送了消息?