How to perform the function of Django by clicking on a button in html template?

There is a function implemented in the Django view, it returns a value. How to call a function from the frontend? I can assume that this is done using django forms and post requests, but I could be wrong. A little idea how to do this if there are multiple functions, and is implemented in a single view all
if request == 'POST':

For example, in php this is implemented by simply tapping the button ID:

function testfun()
echo "Your test function on button click is working";



Skimmed through the documentation, nothing particularly similar not found (maybe bad looking). Point to the right path, please.
April 4th 20 at 13:08
1 answer
April 4th 20 at 13:10
as an option
def your_custom_tag_django (url):
 return "window.location='" + url +"';

<form action="/add/book" method="post">{% csrf_token %}
 {{ form }}
 <button onclick="{% your_custom_tag_django '/books' %}">Cancel</button>
 <button type="submit">OK</button>

Find more questions by tags Django