2
votes

thumbnail in my django project. It require a key value database, my project have redis.

I configured solr.thumbnails with redis:

THUMBNAIL_DEBUG = True
THUMBNAIL_FORMAT = 'PNG'
THUMBNAIL_KVSTORE = 'sorl.thumbnail.kvstores.redis_kvstore.KVStore'
THUMBNAIL_REDIS_HOST = 'localhost'
THUMBNAIL_REDIS_PORT = 6379

Later I activated sorl.thubnails. I copied an static image in my static folder and I put this image in a template with sorl.thumbnails code:

{% load thumbnail %}
{% thumbnail "myimage.png" "100x110" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

It create an image with the correct dimensions in a /cache folder at the root of my project. This image have the correct new dimensions.

cache/c8/1a/c81a5dc6e63107dd2614b2b89d04d4c5.png 

Redis console MONITOR, have a line with the request

1380142932.884816 [0 127.0.0.1:38838] "GET" "sorl-thumbnail||image||789cd5e7c339366b2b99f45d1daf3101"

In the html the image tag is correct:

<img src="cache/c8/1a/c81a5dc6e63107dd2614b2b89d04d4c5.png" width="100" height="110">

But image cannot show, django console says: GET /cache/c8/1a/c81a5dc6e63107dd2614b2b89d04d4c5.png HTTP/1.1" 404 1728

Helpme please, what's wrong?

1

1 Answers

2
votes

Looks like MEDIA_URL is missing.

try doing src="{{MEDIA_URL}}{{ im.url }}"