As_crispy_field cannot re-render the uploaded FileField data from return POST request of Django formset
I have a Django formset that receives the POST request data once submitted, and it saves it (including the uploading file) normally to my database, but if the form is invalid, the page renders again with the same values but missing the selected uploaded file.
I am passing the data to the formset as:
fs = MyFormset(request.POST, request.FILES, .......)
and I am rendering the fields of each form one by one. So, the file field data is:
<div class="col-md-10">
{{ form.included_documents|as_crispy_field }}
</div>
When I submit a new form but it fails in one of the validation criteria, it returns with no file chosen although there was a file chosen. But, if I have a saved form, it renders the uploaded file normally.
Failed Tested Workaround:
According to this Github issue answer, I tested it and it parsed the file input with a better look, but it still fails with parsing the TemporaryUploadedFile.
To make sure that I have the value in my form, I added the below, and it showed the value correctly in the span element not the crispy field element:
<div class="col-md-10">
{{ form.included_documents|as_crispy_field }}
<span>{{ form.included_documents.value }}</span>
</div>
What am I missing here to render the TemporaryUploadedFile in crispy field?