Django:any way to remove this clear field?

You need to change the widget from the ClearableFileInput to Fileinput https://docs.djangoproject.com/en/dev/ref/forms/widgets/#fileinput


Adding to @schacki's answer. Here's how to use the simpler FileInput widget:

# forms.py
from django.forms.widgets import FileInput

class SomeForm(forms.Form):
    foofile = forms.FileField(widget=FileInput)

The default FileField widget seems to be ClearableFileInput.


If you are rendering the ImageField in your template using directly the typical {{ imagefieldname }} you can easily format it just substituting it by a copy-paste of the HTML generated by Django after rendering the template.

You can see that "Clear" checkbox in the HTML generated by Django and delete it if you want.

Tags:

Python

Django