擅长:python、mysql、java
<p>我个人有两种可能的解决方案</p>
<p>1.不用表格</p>
<pre><code> <button type="submit" value={{excel_path}} onclick="location.href='{% url 'downloadexcel' %}'" name='mybtn2'>Download Excel file</button>
</code></pre>
<p>2.使用表格</p>
<pre><code><form action="{% url 'downloadexcel' %}" method="post">
{% csrf_token %}
<button type="submit" name='mybtn2' value={{excel_path}}>Download results in Excel</button>
</form>
</code></pre>
<p>其中url.py应该有这个</p>
<pre><code>path('excel/',views1.downloadexcel,name="downloadexcel"),
</code></pre>