1index.html
2
3<form method="post">
4 {% csrf_token %}
5 <button type="submit" name="run_script">Run script</button>
6</form>
7
8views.py
9
10if request.method == 'POST' and 'run_script' in request.POST:
11
12 # import function to run
13 from path_to_script import function_to_run
14
15 # call function
16 function_to_run()
17
18 # return user to required page
19 return HttpResponseRedirect(reverse(app_name:view_name)