Python django models.ImageField是否在保存之前缓存图像文件?
我知道这是一个愚蠢的问题,但我正在将django与django dropbox存储一起使用。Python django models.ImageField是否在保存之前缓存图像文件?,python,django,caching,Python,Django,Caching,我知道这是一个愚蠢的问题,但我正在将django与django dropbox存储一起使用。 class Product(models.Model): image = models.ImageField(upload_to='images', storage=STORAGE, null=True, blank=True) thumb = models.ImageField(upload_to='thumbs', storage=STORAGE, null=True, blank=
class Product(models.Model):
image = models.ImageField(upload_to='images', storage=STORAGE, null=True, blank=True)
thumb = models.ImageField(upload_to='thumbs', storage=STORAGE, null=True, blank=True)
url = models.TextField(max_length=150, default = 'url')
当我访问django管理员并上传一个图像文件并点击保存按钮时,我想用相同的图像制作一个缩略图并保存它。我可以让它像这样工作:
def save(self):
# create a thumbnail
#self.create_thumbnail()
super(Product, self).save()
url = self.image.url[26:-5]
self.url = "https://dl.dropboxusercontent.com/s/"+url
super(Product, self).save()
#and run the create_thumbnail_function()
#who will download the file from dropbox and then resize it
#and save another time the product model
#super(Product, self).save()
但这意味着服务器会有大量流量,并且会延迟保存。我应该先将图像上传到服务器,然后操作图像并将其保存到dropbox吗?
或者是否可以使用缓存的图像(如果django这样做),对其进行操作,然后将其保存到dropbox?
如果可能,我想获取缓存图像的路径。
谢谢你,对不起我的英语。
任何帮助都将受到感谢