Customization
Customize upload widget
The UploadWidget
and UploadMultipleWidget
is rendered by a template django_file_form/upload_widget.html
, which contains the <input type="file">
widget and a few hidden fields
for additional information.
You can customize the look and feel of the widget by overriding this template. Because Django by default does not use customized templates for form-rendering, you will need to
- Include
django.form
inDJANGO_APPS
- Add
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
tosettings.py
- Add
django_file_form/upload_widget.html
to your projectstemplates
directory (orjinja2
if you use jinja2 to render the templates). The upload widget will be available as variablewidget
and you can use its attributes such aswidget.attrs.id
to customize it.