我收到以下错误:
'MyProfile' object has no attribute 'get_source_filename'
以下代码来自之前回答的SO问题,所以我不确定get_source_filename()是什么或者是什么。谷歌搜索没有任何结果。
class MyProfile(UserenaBaseProfile):
coverpic = models.ImageField(upload_to="site_media/media/covers/", null=True, blank=True)
def save(self, *args, **kwargs):
# Did we have to resize the image?
# We pop it to remove from kwargs when we pass these along
image_resized = kwargs.pop('image_resized',False)
super(MyProfile, self).save(*args, **kwargs)
if self.coverpic:
print "yes"
basewidth = 300
filename = self.get_source_filename()
image = Image.open(filename)
wpercent = (basewidth/float(image.size[0]))
hsize = int((float(image.size[1])*float(wpercent)))
img = image.resize((basewidth,hsize), PIL.Image.ANTIALIAS)
self.coverpic = img
self.coverpic.save