Question

I get this error "employee_directory.thumbnail_kvstore' doesn't exist" when I use sorl-thumbnail to try and format my django admin profile image. Has anyone ran into this while working with sorl-thumbnail and django admin changelist?

DatabaseError at /directory/employee/
(1146, "Table 'employee_directory.thumbnail_kvstore' doesn't exist")

I doubled checked my sorl-thumbnail installation, and made sure I did a syncdb. Below is the code from my models.py and admin.py

models.py:

from django.db import models
from sorl.thumbnail import ImageField

# Department Table
class Department(models.Model):
    department_name = models.CharField(max_length=128)

    def __unicode__(self):
        return self.department_name

# Employee Directory Table
class Employee(models.Model):
    last_name = models.CharField(max_length=32)
    first_name = models.CharField(max_length=32)
    profile_image = models.ImageField(upload_to="images/profile_image", blank=True)
    department_name = models.ForeignKey('Department')
    job_title = models.CharField(max_length=64)
    office_number = models.CharField(max_length=8, blank=True)
    fax_number = models.CharField(max_length=8, blank=True)
    mobile_number = models.CharField(max_length=8, blank=True)
    intercom_number = models.CharField(max_length=3, blank=True)
    email = models.CharField(max_length=128)
    memo = models.TextField(blank=True)


    def __unicode__(self):
        return self.last_name + ', ' + self.first_name

admin.py:

from directory.models import *
from django.contrib import admin
from sorl.thumbnail import get_thumbnail


class EmployeeAdmin(admin.ModelAdmin):

    def profile_img(self, obj):
        if obj.profile_image:
            t = get_thumbnail(obj.profile_image,"50x50",crop='center', quality=99)
            return u'<img src="/media%s"/>' % t.url
        else:
            return u'profile_image'
    profile_img.short_description = 'Profile image'
    profile_img.allow_tags = True


    search_fields = ['last_name', 'first_name']
    list_display = ['profile_img', 'last_name', 'first_name', 'department_name', 
                    'job_title', 'office_number', 'fax_number', 
                    'mobile_number', 'intercom_number', 'email']
    list_filter = ['department_name']




admin.site.register(Department)
admin.site.register(Employee, EmployeeAdmin)

Any help is greatly appreciated.

Was it helpful?

Solution

I totally noobed out, I forgot to put sorl.thumbnail in my apps in the django settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top