sorl-thumbnail does not create cache

117 views
Skip to first unread message

Tao Huang

unread,
Jul 25, 2015, 10:04:16 PM7/25/15
to Django users
I'm using sorl-thumbnail in django. I followed the installation guide. But thumbnail seems not working. It cannot generate cache folder under MEDIA_URL. Also, I checked my mysql database. Table thumbnail_kvstore is always empty.

In settings.py:
INSTALLED_APPS = (
...
'sorl.thumbnail',
)
MEDIA_ROOT
= os.path.join(BASE_DIR, 'media/').replace('\\','/')
MEDIA_URL
= '/media/'

CACHES = {
   
'default': {
       
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
       
'LOCATION': '127.0.0.1:11211',
   
}
}

In urls.py:
urlpatterns = [
url
(r'^admin/', include(admin.site.urls)),
...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

In models.py:
from sorl.thumbnail import ImageField

class Image(models.Model):
    file
= models.ImageField(upload_to="images")
    user
= models.ForeignKey(User)

In template:
{% thumbnail image "100x100" crop="center" as im %}
   
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

It turns out that the im.url generated by thumbnail looks like "/media/cache/6f/9d/6f9dc8d01bf2a23448525d0902a63cd6.jpg". But there isn't a cache folder generated under media/. And thumbnail_kvstore in my database is always empty. Can anyone help me here?
Reply all
Reply to author
Forward
0 new messages