我使用的是django 1.10和最后一个sorl.thumbnail 这是我的 models.py
from sorl.thumbnail import ImageField
class StockImage(models.Model):
image = models.ImageField(upload_to='stock', blank=True, null=True,
verbose_name=_('Image'))
这里是 admin.py
from sorl.thumbnail.admin import AdminImageMixin
class StockImageInline(AdminImageMixin, admin.StackedInline):
model = StockImage
extra = 1
@admin.register(Stock)
class StockAdmin(TranslationAdmin):
group_fieldsets = True
list_display = ('title', 'city', 'start_date', 'finish_date', 'unlimited', 'publish')
inlines = [
StockImageInline,
]