2

I am using the Django Filer to be able to upload multiple images in the Django Admin panel. However, I can't find out how I can fetch these images, so that I can render them in a template/HTML-file.

I know how to fetch images when I am uploading the normal way, as I can reference the model in the template. But I have no idea how I am able to grap the images I have uploaded using Django Filer.

I am Django noob, so sorry if the question seems weird. If anybody have any other suggestions on how to upload multiple images in the Django Admin panel, please come with suggestions.

mrborgen
  • 401
  • 5
  • 10

1 Answers1

6

The answer to your question lies within the documentation of django-filer: http://django-filer.readthedocs.org/en/latest/usage.html#filerfilefield-and-filerimagefield

You need to create a model with a FilerImageField instead of django's ImageField:

from django.db import models

from filer.fields.image import FilerImageField


class ImageModel(models.Model):
    image = FilerImageField()

And you can use easy thumbnail to render it:

{% load thumbnail %}
<img src='{% thumbnail object.image 250x250 crop %}'/>

or just regularly:

<img src='{{ object.image.url }}'/>
Zach
  • 411
  • 3
  • 6