A HTML form that gets submitted by the button click and your Django form handling view can execute the function 3. Thats how we can pass some information from python function to the HTML template in django. The column_3_item.link_for_item is a link to an external website (e.g. www.google.com). jinja2 seems intent on preventing me from making a function call, and insists I repeat myself by copying the function into a template as a macro. There are three ways: 1.

In my template, i have a link button as below when clicked takes you to a different webpage. Open your home.html templateand edit it as shown in screenshot below: So here we are going to show our value assigned to that key name. Questions: I am trying to write a Django application and i am stuck at how i can call a view function when a button is clicked. If we pass any key inside two curly braces then it will give us the value of that key. An AJAX JS call to a Python view that then executes the function you want 2. I have written a custom python script and would like to run a function or .py file when a user presses a "submit" button on the webpage. When the button is clicked, I also want to call a Django view function (along with re-direct to a target website). Perhaps there is a different way of going about this problem, but I am fairly new to using Django. Questions: I am using jinja2, and I want to call a python function as a helper, using a similar syntax as if I were calling a macro. The view function increments the value in the database which stores the number of times the button is clicked. So let’s run it in browser.