I am working on a project where we want to use different file input widgets for different use cases; obviously we'd like to inherit from the existing Django file inputs to reduce code re-use and get Django's file handling for free. However, we discovered that templates/bootstrap5/field.html explicitly disallows this for file inputs, e.g.
{% if field|is_file %}
{% include 'bootstrap5/layout/field_file.html' %}
{% elif field|is_select %}
...
Our current workaround is to manually copy the contents of Django's FileInput and ClearableFileInput to custom input fields which we can then use to create a custom widget; however, this is clearly not a preferable solution. My questions are:
- is there a reason to explicitly disallow setting a custom File input?
- could support be added to override the file field rendering by e.g. using the same
crispy_field approach used for other input types?
I am working on a project where we want to use different file input widgets for different use cases; obviously we'd like to inherit from the existing Django file inputs to reduce code re-use and get Django's file handling for free. However, we discovered that
templates/bootstrap5/field.htmlexplicitly disallows this for file inputs, e.g.Our current workaround is to manually copy the contents of Django's
FileInputandClearableFileInputto custom input fields which we can then use to create a custom widget; however, this is clearly not a preferable solution. My questions are:crispy_fieldapproach used for other input types?