【发布时间】:2017-12-17 11:52:35
【问题描述】:
只是想知道是否可以使用 Sessions 在我的 Django 应用程序上创建两个产品的快速比较视图。我正在列出待售商品,并希望用户能够“喜欢”多个商品,然后有一个新视图来比较所选产品。有什么想法吗?
谢谢
【问题讨论】:
标签: python django python-3.x web django-sessions
只是想知道是否可以使用 Sessions 在我的 Django 应用程序上创建两个产品的快速比较视图。我正在列出待售商品,并希望用户能够“喜欢”多个商品,然后有一个新视图来比较所选产品。有什么想法吗?
谢谢
【问题讨论】:
标签: python django python-3.x web django-sessions
当然,只需将列表产品分配给会话变量即可。
然后将产品列表分配给模板,它可能看起来像这样:
<table>
<tr>
<td></td>
{% for product in products %}
<th>{{ product.title }}</th>
{% endfor %}
</tr>
<tr>
<th>Feature 1</th>
{% for product in products %}
<td>{{ product.feature1 }}</td>
{% endfor %}
</tr>
<tr>
<th>Feature 2</th>
{% for product in products %}
<td>{{ product.feature2 }}</td>
{% endfor %}
</tr>
</table>
【讨论】: