我将 Grappelli 与 Filebrowser 一起使用,在上传文件扩展名为大写(image.PNG)的图像时发现了一个错误。如果它们以大写结尾,则每次刷新文件浏览器页面时都会创建一个缩略图。
我在文件浏览器包中找到了这个方法:
def handle_file_upload(path, file, site):
"""
Handle File Upload.
"""
uploadedfile = None
try:
file_path = os.path.join(path, file.name)
uploadedfile = site.storage.save(file_path, file)
except Exception, inst:
raise inst
return uploadedfile
为了解决这个错误,我希望它看起来像这样:
def handle_file_upload(path, file, site):
"""
Handle File Upload.
"""
uploadedfile = None
try:
file_path = os.path.join(path, file.name.lower())
uploadedfile = site.storage.save(file_path, file)
except Exception, inst:
raise inst
return uploadedfile
如何在不更改包文件的情况下执行此操作?当我更新 Filebrowser 时,我不希望我的修复消失。
我可以只覆盖那个方法吗?或者我应该使用信号还是什么?