django thumbnail img url does not correctly rendered in html

613 views Asked by At

This is HTML code piece that in my template:

{%load thumbnail%}
<img style="border: 1px solid #53BCB8; padding: 2px;" src="{%thumbnail 'photodir/photo.jpg' 256x256%}" />

And in my settings.py

MEDIA_URL="http://url.com/static/"

And this is the rendered state of HTML:

<img style="border: 1px solid #53BCB8; padding: 2px;" src="http://url.com/staticphotodir/photo_jpg_256x256_q85.jpg" />

the problem is: in the rendered html, img url does not valid. Trailing slash is missing between "static" and "photodir". How is that happenning and what is the solution? Can anybody explain?

Note: thumbnail template tag belongs to sorl-thumbnail

1

There are 1 answers

1
Michael Samoylov On BEST ANSWER

Have a look, I created a test project for you. It works like a charm with:

Django==1.3.1
Pillow==1.7.6
sorl-thumbnail==11.12

I get /media/cache/77/c6/77c60cc55e126abe02cbe5de48693c80.png as the result. So it seems that your MEDIA_ROOT variable contains a wrong value. Please ensure it has a trailing slash.