title: Add two numbers in django and output will print same on same page
body: <p>I'm new to django and I need to add two numbers x and y .</p>
  
  <p>The x and y are inputs from user.</p>
  
  <p><strong>Here is my views.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from django.shortcuts import render
  from django.http import HttpResponse
  
  def home(request):
      return render(request, 'home.html', {'name':'keyur'})
  
  def add(request):
  
      val1 = int(request.POST['num1'])
      val2 = int(request.POST['num2'])
      # red = add('val1','val2')
      res = val1 + val2
      return render(request,'home.html',{'result': res})
  </code></pre>
  
  <p><strong>Here is my url.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from django.urls import path
  
  from . import views
  
  urlpatterns = [
      path('', views.home, name='home'),
      path('add', views.add, name='add')
  
  ]
  </code></pre>
  
  <p><strong>Here is my home.html</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>{% extends 'base.html'  %}
  
  {% block content %}
  
  &lt;h1&gt;hello {{name}} !!!!&lt;/h1&gt;
     &lt;form action="add" method="post"&gt;
      {% csrf_token %}
                  Enter a 1st number: &lt;input type="text" name="num1"  placeholder="enter the number"&gt;
                  Enter a 2st number: &lt;input type="text" name="num2" placeholder="enter the number"&gt;
                  &lt;input type="submit"&gt;
  
              &lt;/form&gt;
  
  
  {% endblock %}
  </code></pre>
  
  <p><strong>Here is my result.html</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>{% extends 'base.html'  %}
  
  {% block content %}
  
      Result is... {{result}}
  
  {% endblock %}
  
  </code></pre>
  
  <p>I want to print the output in same page. Can anyone please help me?</p>