Reputation: 37
here i have a form i did find were to control label and input field of the imagefield but label only controls the Avatar text not the "currently ....ect",
is there a way to access it i want to add a class to style it and cant find its object in python ?
this my attempt and it is not working only gives me the "avatar" ext only
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
Upvotes: 0
Views: 462
Reputation: 73450
These are defined in ClearableFileInput
:
class ClearableFileInput(FileInput):
clear_checkbox_label = _('Clear')
initial_text = _('Currently')
input_text = _('Change')
# ....
So you would have to subclass this widget, override the class attributes, and use it in the form field. Alternatively, you can override the template forms/widgets/clearable_file_input.html
for total control over the display of the generated markup of the field.
Upvotes: 1