L
L
Legalas612019-11-18 22:40:50
Django
Legalas61, 2019-11-18 22:40:50

Why is part of the column data being output from the database?

I use cloudinary to store images. I upload them through the native junga admin panel:

images = CloudinaryField('Картинка для главной страницы', null=False, width_field='image_width',
                             height_field='image_height')

in sqllite I get image/upload/v1574103384/hdvil4trb3bdijby74u8.jpg , which suits me.
In the admin panel, in general, a direct link:
5dd2f349c5218090830952.png
I display it in the template like this:
<img class="main_img" src='{{ post.images }}' alt="{{ post.title }}">

I get:
<img class="main_img" src="vcoxk9dkjgfqfjicr1dl" alt="Первая статья">

The problem is that / v1574103384 / hdvil4trb3bdijby74u8 .jpg are unique for each picture
. Where did I go wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-11-26
@Legalas61

Cloudinary has a template tag:

{% load cloudinary %}
{% cloudinary photo.image.public_id className="my-class" height=200 width=100 %}

Or in a simple way, you can do this: photo is the name of the model. Why is images plural if there is only one picture?

D
dcontm, 2019-11-22
@dcontm

Try adding '.url' after the name-

<img class="main_img" src='{{ post.images.url}}' alt="{{ post.title }}">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question