Django:Photologue 不显示模板中的图像

发布于 2024-08-09 01:21:34 字数 806 浏览 7 评论 0原文

我正在尝试安装 django-photologue。一切看起来都很好,因为我按照官方指南安装和设置。我必须上传一些照片作为示例。但是,当查看照片或图库详细信息时,出现如下错误:

Caught an exception while rendering: 'Photo' object has no attribute 'get_thumbnail_url'

我尝试从文件 photo_detail.html 中删除以下代码

{% if object.public_galleries %}
<h2>This photo is found in the following galleries:</h2>
<ol>
{% for gallery in object.public_galleries %}
    <li>{%previous_in_gallery object gallery%} <a href="{{ gallery.get_absolute_url }}">{{ gallery.title }}</a> {%next_in_gallery object gallery%}</li>
{% endfor %}
</ol>
{% endif %}

,没有更多错误,但图片不显示。如果你点击链接仍然会导致正确的照片看到。我认为问题在于:

{{ object.get_display_url }}

它完全没有返回任何值。 请帮我解决这个问题。谢谢!

I am trying to install django-photologue. Everything seems ok, because I install and set up following the official guidelines. I have to upload some photos as examples. However, when viewing a photo or gallery details , then an error as follows:

Caught an exception while rendering: 'Photo' object has no attribute 'get_thumbnail_url'

I tried to remove the following code from the file photo_detail.html

{% if object.public_galleries %}
<h2>This photo is found in the following galleries:</h2>
<ol>
{% for gallery in object.public_galleries %}
    <li>{%previous_in_gallery object gallery%} <a href="{{ gallery.get_absolute_url }}">{{ gallery.title }}</a> {%next_in_gallery object gallery%}</li>
{% endfor %}
</ol>
{% endif %}

No more errors, but pictures do not show up. If you click on the link will still lead to correct photographs to see. I think the problem in:

{{ object.get_display_url }}

It is totally not return any value.
Please help me solve this problem. Thanks!

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

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

发布评论

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

评论(3

妖妓 2024-08-16 01:21:34

在其他版本中,您必须编辑 photologue/templates/photolog/tags/next_in_gallery.html 并将

{{ photo.get_thumbnail_url }}

替换为Same。

{{ photo.thumbnail.url }}

photologue/templates/photolog/tags/prev_in_gallery.html

In other versions, you have to edit photologue/templates/photolog/tags/next_in_gallery.html and replace

{{ photo.get_thumbnail_url }}

with

{{ photo.thumbnail.url }}

Same for photologue/templates/photolog/tags/prev_in_gallery.html.

仅此而已 2024-08-16 01:21:34

您是否在安装后运行python manage.py plinit并选择创建缩略图显示照片大小?这些照片尺寸需要在您的数据库中定义。

Did you run python manage.py plinit after install and opt to create both a thumbnail and display photosize? These photosizes need to be defined in your database.

稀香 2024-08-16 01:21:34

老实说,从源代码来看,它看起来像是项目中的一个错误。如果您搜索源代码,缩略图似乎不是 Photo 类中的字段(get_FIELD_url 是一种简单的方法顺便说一句,访问 ImageField 的 url。)所以我建议修改源代码或寻找另一个项目。虽然我可能是错的,但这就是我对项目进行约 5 分钟扫描后发现的结果。

Honestly from looking at the source, it looks like a bug in the project. If you search the source, thumbnail doesn't seem to be a field within the Photo class (get_FIELD_url is an easy way to access an ImageField's url btw.) So I would recommend tinkering with the source or finding another project. I might be wrong though but that's what my ~5 minute scan of the project found.

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