django-crispy-forms / django-crispy-forms/crispy-bootstrap5
Cannot use custom file input widgets
- Dominant language
- HTML
- Stars
- 525
- Forks
- 77
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 2
Description
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:
1) is there a reason to explicitly disallow setting a custom File input?
2) could support be added to override the file field rendering by e.g. using the same `crispy_field` approach used for other input types?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.