Photologue not showing images or thumbnails

195 Views Asked by At

I am not able to get photologue to show the images. What am I doing wrong?

development environment

  • django 2.1
  • python 3.5
  • osx, virtual_env, recent pip

settings.py

MEDIA_ROOT = os.path.join(BASE_DIR, 'mst/media/')
MEDIA_URL = "/media/"

urls

urlpatterns += [
    ...
    url(r'^photologue/', include('photologue.urls', namespace='photologue')),
]
model
from photologue.models import Photo, Gallery

class PhotoExtended(models.Model):
    photo = models.OneToOneField(Photo, on_delete=models.CASCADE, related_name='photo')
    related_model = models.ForeignKey(MyModel, on_delete=models.CASCADE)

    def __str__(self):
        return self.photo.title

class GalleryExtended(models.Model):
    gallery = models.OneToOneField(Gallery, on_delete=models.CASCADE, related_name='gallery')
    related_model = models.ForeignKey(MyModel, on_delete=models.CASCADE)

    def __str__(self):
        return self.gallery.title

class based view

class MyModelList(ListView):
    model = MyModel
    template_name = "pictures.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['photos'] = PhotoExtended.objects.all()
        context['galleries'] = GalleryExtended.objects.all()
        return context

template (pictures.html):

{% block content %}
    <ul>
        {% for photoExtended in photos %}
            <li>{{ photoExtended.photo.get_absolute_url }}</li>
            <li>{{ photoExtended.photo.image }}</li>
            <img src="/{{ photoExtended.photo.image }}" alt="{{ p.photo.title }}">
        {% endfor %}
        {% for gallery in galleries %}
          <li></li>
        {% endfor %}

shell response (per docs)

>>> from PIL import Image
>>>

notes

I migrated the database, and see the data in the database, and everything looks correct.




page renderings

photologue urls:

A single photo

a single image

the list of the photos a list of photos

and the direct accessing of the image: (ra is the name in photologue, but em.jpeg is the file name)

direct access of the image

and my view directly:

enter image description here

1

There are 1 best solutions below

0
chris Frisina On

The template was wrong/outdated from an older version. Here is the correct usage in the template for an image within a list of images of type photologueExtended:

{% for photoExtended in photos %}            
    <!-- The link to the photologue template page with the photo and its gallery(s)-->
    <a href="{{ photoExtended.photo.get_absolute_url }}">Link to page</a>
    <!-- The src link to the image thumbnail itself in the media url-->
    <img src="{{ photoExtended.photo.get_thumbnail_url }}" />
    <!-- The src link to the image itself in the media url-->
    <img src="{{ photoExtended.photo.get_display_url }}" />
    <!-- The photologue image's title/description/etc… -->
    {{ photoExtended.photo.title }} <br>
    {{ photoExtended.photo.description }} <br>
{% endfor %}

Also:

the url catchall in the main project urls.py was incorrect, and should be:

url(r'^$', indexView, name='indexView'),