为什么 sorl.thumbnail ImageField 在管理中失败?
我的代码如下所示:
from sorl.thumbnail import ImageField
class Gallery(models.Model):
pass
class GalleryImage(models.Model):
image = ImageField(upload_to='galleries')
在管理中:
class GalleryImageInline(admin.TabularInline):
model = GalleryImage
class GalleryAdmin(admin.ModelAdmin):
inlines = (GalleryImageInline,)
如果我使用上面的 sorl.thumbnail,则无法在管理中添加图像。我收到验证错误
Enter a list of values.
如果我用普通的 django ImageField 替换 sorl.thumbnail.ImageField ,一切正常。
如果我想要 sorl.thumbnail 清理缓存缩略图,我需要在模型中使用它,但是如果我在模型中使用它,我似乎无法添加任何需要缩略图的图像。
还有其他人发现并解决了这个问题吗?
I have code that looks like this:
from sorl.thumbnail import ImageField
class Gallery(models.Model):
pass
class GalleryImage(models.Model):
image = ImageField(upload_to='galleries')
In the admin:
class GalleryImageInline(admin.TabularInline):
model = GalleryImage
class GalleryAdmin(admin.ModelAdmin):
inlines = (GalleryImageInline,)
If I use the sorl.thumbnail as above, it is impossible to add images in the admin. I get the validation error
Enter a list of values.
If I replace the sorl.thumbnail.ImageField with a plain django ImageField, everything works.
If I want sorl.thumbnail to clean up the cache thumbnails, I need to use it in the model, but if I use it in the model, I can't seem to add any images to need thumbnails.
Anyone else found and fixed this problem yet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉回复晚了,请参阅:
https://github.com /sorl/sorl-thumbnail/issues/issue/14/#comment_642425
Sorry for the late answer, please see:
https://github.com/sorl/sorl-thumbnail/issues/issue/14/#comment_642425
进口声明应为:
Import statement should be: