我打算ThumbnailBackend
从sorl.thumbnail.base
. 我需要做的是覆盖该_get_thumbnail_filename
方法,在原始(父)方法生成的文件名中添加一些东西。为此,我写了这样的东西:
from sorl.thumbnail.base import ThumbnailBackend
class MyThumbnailBackend(ThumbnailBackend):
def _get_thumbnail_filename(self, source, geometry_string, options):
oldpath = super(ThumbnailBackend,self)._get_thumbnail_filename(source, geometry_string, options)
oldpathlist = oldpath.split('/')
# get the last item of 'oldpathlist' and
# sufix it with useful info...
# join the items with the modified one...
return newpath
python继承应该缺少一些东西,因为我不断收到以下错误:
AttributeError at /location/of/the/caller/class/
'super' object has no attribute '_get_thumbnail_filename'
如果我是对的,我将在第一行导入这个类:from sorl.thumbnail.base import ThumbnailBackend
它肯定有一个_get_thumbnail_filename
方法。
我究竟做错了什么?
非常感谢!