title: How to execute python code by django html button?
body: <p>I want to execute my python code by onclick. I am getting result after running the server. My button is not working. Here is my code. </p>
  
  <p>URL - </p>
  
  <pre><code>url(r'^index/$', index),
  </code></pre>
  
  <p>index.html-</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
    &lt;form action="/index/" method="GET"&gt;
      &lt;input type="submit" value="Click"&gt;
    &lt;/form&gt;
    {{output}}
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>views.py - </p>
  
  <pre><code>from django.shortcuts import render, render_to_response
  from pythoncode import mycode
  def index(request):
      if request.method=="GET":
          py_obj=mycode.test_code(10)
          py_obj.code()
          return render(request, 'index.html', {"output":py_obj.a})
  </code></pre>
  
  <p>I created one more application to separate python code -
  application name is python code and file name mycode</p>
  
  <pre><code>class test_code:
      def __init__(self, a):
          self.a=a
          self.b=4
      def code(self):
          return self.a, self.b
  </code></pre>
  
  <p>please help me. I am new in Django. Thanks in advance</p>