pythondjangohtmlimageuploadcare

Django - displaying images on the page using pyuploadcare


Python, Django, pyuploadcare, html5, jquery,
The Django documentations for pyuploadcare are useful for image customization and file uploading and stuff like that, but what they don't tell you is how to display the image in the webpage. For example, i can display the URL where the image is stored, but i cannot display the image itself in the webpage
i want to make this as clear as possible to the reader so I'll give another example:
To build an image gallery, i would need all the images displayed on one page, i can do that using the for loops

for photo in photos

Photo and photos are defined in views.py

{% extends 'base.html' %}

{% for photo in photos %}


{{ photo.caption }}
{{ photo.photo }}

{% endfor %}

{% block content %}
{% endblock %}

photo.caption is an models.CharField()
photo.photo is an ImageField() from

from pyuploadcare.dj.models import ImageField

everything is working properly but i don't know how to display the images on the webpage. Any help would be apreciated


Solution

  • Simple <img src="{{ photo.photo }}" /> should be enough, as ImageField just holds the CDN URL value.