How to autofill a django form by just uploading a excel file in upload section

Is there a way to have a button that uploads an excel file and automatically fills a given form with the excel data I don’t want to have a submit button but once the user choses the file, the result should be automatic populating values in the fields.

That work would need to be done in JavaScript.

I can think of doing this in at least two different ways.

  • You could write the JavaScript to read the file using the FileReader API, and then populate the form fields with the data.

  • Or, you could do the work server-side by having the JavaScript issue an AJAX call to the server and pass the file to the server. The server could then read the file and return the field data to be populated in the form by the JavaScript, or it could re-render the form and send back the entire new HTML for the form.

Either way is going to require the JavaScript to handle this without doing a Submit.

Do you have any basic code of javascript to populate the data ?

From a file? No.

Assuming you’ve already got the data somehow, updating the form is an issue of setting the value on the input element.