If someone wants to add another field like a ChoiceField and/or CharField since the upload button immediately triggers a POST request there's no chance to send other field within the request and therefore form never gets validated. Is it possible to after uploading the files use another submit button for submitting the form include uploaded files at once? some thing like the following snippet?
<form action="/" method="POST">{% csrf_token %}
<div class="custom-select" style="width:200px;">
<li>{{ form.interface.label_tag }} {{ form.interface }}</li>
</div>
<div class="custom-select" style="width:200px;">
<li>{{ form.environment.label_tag }} {{ form.environment }}</li>
</div>
<br>
<div style="margin-bottom: 20px;">
<button type="button" class="btn btn-primary js-upload-photos">
<span class="glyphicon glyphicon-cloud-upload"></span> Upload files
</button>
<input id="fileupload" type="file" name="file" multiple
style="display: none;"
data-url="{% url 'home' %}"
data-form-data='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'>
<br>
</div>
<div style="margin-bottom: 20px;">
<button type="submit" class="btn btn-success">
<span class="glyphicon glyphicon glyphicon-ok"></span> Submit
</button>
</div>
</form>
In this case, If I hit the submit it raise the field required error for file field and if I hit the upload it raises the error for other fields.
If someone wants to add another field like a
ChoiceFieldand/orCharFieldsince the upload button immediately triggers a POST request there's no chance to send other field within the request and thereforeformnever gets validated. Is it possible to after uploading the files use another submit button for submitting the form include uploaded files at once? some thing like the following snippet?In this case, If I hit the submit it raise the
field requirederror forfilefield and if I hit the upload it raises the error for other fields.