Reputation: 3888
I'm trying to integrate sorl-thumbnail into an existing project to show thumbnails of ImageField photos in the django admin, however am having no results.
I installed sorl using
pip install sorl-thumbnail
then added
'sorl.thumbnails'
to settings.py
then ran manage.py syncdb
, then set up admin.py with
from django.contrib import admin
from myapp.models import MyModel
from sorl.thumbnail.admin import AdminImageMixin
class MyModelAdmin(AdminImageMixin, admin.ModelAdmin):
pass
Though I still don't see a thumbnail on my django admin when viewing the listing for MyModel
or when I look at each individual MyModel
What am I doing wrong?
nb: I am using South for migrations and S3 to store the static images for my app
Upvotes: 2
Views: 1427
Reputation: 239380
AdminImageMixin
changes the widget for the ImageField
only if it's an instance of sorl-thumbnail's ImageField
. So your model needs to use the following:
from sorl.thumbnail import ImageField
class MyModel(models.Model):
some_image = ImageField(...)
Instead of django.db.models.ImageField
.
If you've done that, the img
tag for the thumbnail should be being added next to the field in the admin source, if it is in fact in the source, it might be an issue with storing the files on S3 and the URL being used by sorl-thumbnail doesn't match.
Upvotes: 3