Django:Photologue 不显示模板中的图像
我正在尝试安装 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在其他版本中,您必须编辑 photologue/templates/photolog/tags/next_in_gallery.html 并将
替换为Same。
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
with
Same for photologue/templates/photolog/tags/prev_in_gallery.html.
您是否在安装后运行
python manage.py plinit
并选择创建缩略图
和显示
照片大小?这些照片尺寸需要在您的数据库中定义。Did you run
python manage.py plinit
after install and opt to create both athumbnail
anddisplay
photosize? These photosizes need to be defined in your database.老实说,从源代码来看,它看起来像是项目中的一个错误。如果您搜索源代码,缩略图似乎不是 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.