ImageField / FileField Django form Currently unable to trim the path to filename

对着背影说爱祢 提交于 2019-12-02 04:05:12
DhiaTN

In Django 1.11.x get_template_substitution_values is deprecated. New implementation of CustomClearableFileInput could be as follow:

class CustomClearableFileInput(ClearableFileInput):
    def get_context(self, name, value, attrs):
        value.name = path.basename(value.name)
        context = super().get_context(name, value, attrs)       
        return context
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!