开发者

Django: Photologue does not show images in templates

开发者 https://www.devze.com 2022-12-09 15:21 出处:网络
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 o

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>
{% end开发者_StackOverflow中文版for %}
</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!


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消