I am using sorl thumbnails to generate thumbnails in a view. I installed
mysql-python
Django==1.6.1
Pillow==2.3
sorl-thumbnail==11.12.1b
I have added
THUMBNAIL_DEBUG = DEBUG
and
'sorl.thumbnail',
to INSTALLED_APPS in settings.py.
Ran
./manage.py syncdb
which created the "thumbnail.kvstore" table in my "archives" database and have the following in my model:
from sorl.thumbnail import ImageField
class relic(models.Model):
...
photo = ImageField(upload_to='photo', blank=True, null=True)
In my view I have
# all the relics for the given historical site (hsite_id)
def relicList(request, hsite_id):
print hsite_id
theSite = historical_site.objects.get(pk=hsite_id)
relicSet = theSite.relic_set.all()
return render_to_response('archives/relic_list.html', locals())
# end relicList
In my template I have
{% extends "base.html" %}
{% load thumbnail %}
{% load staticfiles %}
{% for relic in relicSet %}
<!-- alternate colours with the classes defined in the style sheet -->
<tr class={% cycle "odd" "even" %}>
<td>{{ relic.name }}</td><td>{{ relic.description }}</td>
<td>
{% if relic.photo %}
<a href="{{ relic.photo.url }}">
{% thumbnail relic.photo "100x100" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
Loading the template gives me
ProgrammingError: (1146, "Table 'archives.sessioncache' doesn't exist")
Trying a few other things I tried
(archeologist)jason:>./manage.py shell
>>> from achives.models import *
>>> from sorl.thumbnail import get_thumbnail
>>> myRelics = relic.objects.all()
>>> for r in myRelics:
... print r.photo
etc
>>> print r.photo
photo/image_9.jpg
>>> im = get_thumbnail(r.photo, '100x100', crop='center')
I get the same error
ProgrammingError: (1146, "Table 'archives.sessioncache' doesn't exist")
I don't have memcached installed, and I already use thumbnails successfully from another project that uses postgres. I don't want to use memcached, as this is a small project. What am I missing?
I found the error in my settings.py file. I had this setting, which I did not understand
CACHES = {
'default': {
'BACKEND' : 'django.core.cache.backends.db.DatabaseCache',
'LOCATION' : 'sessioncache',
}
}
Once I commented it out, thumbnails worked fine.