In this method, we will create and define a function in the HTML document's head section. To invoke this function in the html document, we have to create a simple button and using the onclick event attribute which is an event handler along with it, we can call the function by clicking on the button. In the above-given program, we have created a simple HTML document. Inside the head section of the HTML document, we have defined a function e. On the other hand, inside the body section, we displayed some text and created a button. To call our function, we have used the onclick attribute along with the button and when the user clicks on that button our function gets executes and display an alert message, as you can see in the output.
Django is a python framework for web development which works on jinja2 templating engine. When data is rendered along with the template after passing through views. As django is a backend framework, hence to use the power of python to use that data dynamically requests need to be generated.