使用 Django 和 django-imagekit 在对象列表中显示缩略图

发布于 2024-08-12 23:34:54 字数 163 浏览 4 评论 0原文

如何显示我的项目列表的缩略图......是否可以仅显示特定缩略图或随机缩略图?到目前为止,我的模板中有这样的内容:

{% for p in item.images.all %}
   {{ p.get_thumbnail.url }}
{% endfor %}

How do I display thumbnails for my item list....also is it possible to display just a specific thumbnail or a random thumbnail? So far I have this in my template:

{% for p in item.images.all %}
   {{ p.get_thumbnail.url }}
{% endfor %}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙气飘飘 2024-08-19 23:34:54

要显示图像,您至少需要使用 标签:

 <img src="{{ p.thumbnail_image.url }}" alt="{{ p.name }}">

To display the image, you'll at least need to use an <img> tag:

 <img src="{{ p.thumbnail_image.url }}" alt="{{ p.name }}">
鸠魁 2024-08-19 23:34:54

刚刚得到问题的答案:

{% for p in item.images.all|slice:"4" %}

Just got an answer to the problem:

{% for p in item.images.all|slice:"4" %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文