Not display "Currently" with a ClearableFileInput


I have a form which allow the user to upload a logo. As I display the logo on the screen () I don’t need to have the “Currentl” text followed by the link of the file. I guess I have to customize the class ClearableFileInput but what I’ve triid so far does not work.

The field definition in the “Param” Model:

UW_logo = models.ImageField("Logo:", upload_to='logos/', null=True, blank=True)

My form:

class CustomClearableFileInput(ClearableFileInput):
    def get_context(self, name, value, attrs):
        context = super().get_context(name, value, attrs)
        context["widget"]["initial_text"] = "Texte initial personnalisé"
        return context

class ParametersForm(ModelForm):
class Meta:
        model= Param
        #fields = '__all__'
        exclude = ['UW_Sirene_API_consumer_key','UW_Sirene_API_consumer_secret',
                   'UW_Sirene_API_access_token', 'UW_Sirene_API_access_token_expiration_date',
        widgets = {'UW_logo': CustomClearableFileInput(attrs={'class': 'form-control-file'})},
        #widgets = {'UW_logo': forms.ClearableFileInput(attrs={'class': 'form-control-file'})}

        labels = {'UW_logo': "Logo actuel"}

The html piece of code:

        <div class=" col-md-1 d-flex align-items-center">
          <label for="{{form.UW_logo.id_for_label}}" class="mx-2 text-secondary">{{form.UW_logo.label}}</label>
        <div class="col-md-6 d-flex align-items-center">
          <div class="position-relative ">
            {% if form.instance.UW_logo %}
                <img src="{{ form.instance.UW_logo.url }}" alt="Logo" class="logo-img">
            {% else %}
            {% endif %}
          <div class="fieldWrapper">{{form.UW_logo.errors}}</div>

I also tried the following for my CustomClearableFileInput:

class CustomClearableFileInput(ClearableFileInput):
    initial_text = "Texte initial personnalisé"

I alway get the “Currently” text followed by the link.

Any help would be appreciated to get rid of this text and the link (as you may have notice in the html, I displayed the logo, if any)


If you want to completely remove the “Currently” and the link, you’ll want to create a custom template. You can use the existing template as a guide and set the template_name attribute on the widget to use it. See Widgets | Django documentation | Django

If you just want to change the label like you’re trying to do here - that should work. (It works in my test environment.) If it’s not working for you, there’s something else wrong.