我正在尝试安装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 }}

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

有帮助吗?

解决方案

您是否在安装后运行 python manage.py plinit 并选择同时创建 thumbnail display photosize?这些照片化需要在您的数据库中定义。

其他提示

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

{{ photo.get_thumbnail_url }}

{{ photo.thumbnail.url }}

对于photologue / templates / photolog / tags / prev_in_gallery.html相同。

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top