Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Django Program to perform addition using three buttons: code

from django.shortcuts import render

def index(request):
if request.method=='POST' 
p = request.POST["txtp"]
r = request.POST["txtr"]
if request.POST['btnsubmit']=='+':
elif request.POST['btnsubmit']=='-':
elif request.POST['btnsubmit']=='*':
return render(request,"siapp/index.html",{'res':c})
return render(request,"siapp/index.html")

code of index.html

<!DOCTYPE html>
<link href="/static/style.css"  type="text/css" rel="stylesheet" />

<center><h1>SI FORM </h1></center>
<div style="padding-top:50px;padding-left: 200px; ">
  <form action="" method="post">
  {% csrf_token  %}
    <input type="number" name="txtp" placeholder="Enter first number" required="" />
    <input type="number" name="txtr" placeholder="Enter second number" required="" />
    <input type="submit" name="btnsubmit" value="+" />
    <input type="submit" name="btnsubmit" value="-" />
    <input type="submit" name="btnsubmit" value="*" />

code of

from django.urls import path
from . import views


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post