我想添加一个在django管理网站的图像裁剪功能。我不知道我如何才能做到这一点。我已经使用了django-图像裁剪应用程序,但不能为管理员端集成此程序。
发布于 2012-04-02 20:30:30
您应该在模型中定义save()方法:
class MyImage(models.Model):
image = models.ImageField(...)
image_crop = models.ImageField(blank=True)
def save():
super(MyImage, self).save() #will save only image, image_corp will be blank.
image_path = self.image.path #path to your non croped image
#now you can load image file and crop it usung PIL and save.
self.image_crop = 'path/to/cropped/image' #add path to cropped image.
super(MyImage, self).save() #save data.https://stackoverflow.com/questions/9974416
复制相似问题