'How to create a button that submit a form and download file in Django

How to create a button that submit a form and download file in Django

I know use this code and download file

<html>
<title>Download File</title>
</head>
<body>
<enter>
   <h1>Download File using Django</h1>
   <a href="{% url 'download_pdf_file' filename='CF.pdf' %}">Download PDF</a>
</center>
</body>
</html>

I also know how to create a button that submit some data

<input type="submit" value='submit' class="btn btn-primary btn-sm">

But how could I combine them into in button

The reason why I need to do that is I want to update the exist file and download it in the same page.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source