【发布时间】:2020-05-28 23:44:59
【问题描述】:
在我的 home.html 模板中:
<button type="button" class="btn btn-dark"
method = 'GET' action = '/action_name/' name="audio_record">Record Audio</button>
在我看来.py:
def audio_functions(request):
print('called function')
在我的 urls.py 中:
path('/action_name/', views.audio_functions, name='audio-record'),
我做错了什么?
编辑:我将按钮替换为以下建议的版本:
<a href="{% url 'audio-record' %}" class="btn btn-dark"
>Record Audio</a>
但是我有一个新问题。我实际上不想通过 url/action_name 重定向到。我只想在浏览器中触发 python 脚本。我该怎么做?
【问题讨论】: