如何编辑 imageField 标签文本 "Currently, ... ect"

How to edit the imageField label text "Currently, ... ect"

在这里我找到了一个表格来控制图像字段的标签和输入字段,但标签只控制头像文本而不是“当前....ect”,

有没有办法访问它我想添加一个 class 来设置它的样式但在 python 中找不到它的对象?

这是我的尝试,但它不起作用只给了我“头像”分机

class ProfileUpdateModelForm(ModelForm):
    class Meta:
        model = Profile
        fields = ('first_name', 'last_name', 'bio', 'avatar')

    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.fields['avatar'].label = False #hides "avatar" text and the rest of text still there

这些定义在 ClearableFileInput:

class ClearableFileInput(FileInput):
    clear_checkbox_label = _('Clear')
    initial_text = _('Currently')
    input_text = _('Change')
    # ....

因此您必须子class 这个小部件,覆盖class 属性,并在表单字段中使用它。或者,您可以覆盖模板 forms/widgets/clearable_file_input.html 以完全控制字段生成标记的显示。