Django: Photologue does not show images in templates

3.3k views Asked by At

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!

3

There are 3 answers

1
Justin Driscoll On BEST ANSWER

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.

0
Bartek On

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
Marius On

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.