目前,我正在使用非硬编码的url通过匹配条形码编号将用户重定向到具有类似产品的页面。在
视图.py
def ItemView(request, barcode):
template_name = "TESTcategories.html"
products = Product.objects.filter(barcode=barcode)
context = {
'products': products,
}
return render_to_response(template_name, context)
网址.py
^{pr2}$项目.html
<h3 class="product-title"><a href="{% url 'ItemView' result.object.barcode %}">{{result.object.title}}</a></h3>
我根据URL模式传递条形码参数。我是否可以达到类似的效果,但对于“快速查看”选项,将启动弹出模式视图。 这是我的潜在模式:
部分/模态.html
<!-- Large Modal-->
<div class="modal fade" id="modalLarge" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Quick Item Compare</h4>
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<!-- Product in modal -->
<div class="table-responsive">
<table class="table">
{% for result in page_obj.object_list %}
<thead>
<tr>
<th></th>
<th>{{result.object.title}}</th>
<th></th>
<th></th>
<th>£{{result.object.price}}</th>
<th class="text-center"><a class="btn btn-sm btn-btn btn-success" href="{{result.object.url}}">Visit Site</a></th>
</tr>
</thead>
{% endfor %}
</table>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-sm" type="button" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
编辑:在我的模态.html结果在页面上迭代_目标对象清单因为我用djang haystack和弹性搜索。在
目前没有回答
相关问题 更多 >
编程相关推荐