title: Drawing shapes on html canvas in python/django
body: <p>I am trying to draw shapes, line, triangles, rectangle on a web page using Django. How to accomplish this? Below is my code. </p>
  
  <p>views.py</p>
  
  <pre><code>import tkinter
  from django.shortcuts import render
  from django.http import HttpResponse
  from django.template import loader
  
  def drawchart():
          root = tkinter.Tk() 
          canvas = root.Canvas(root, width=400, height=500)
          canvas.pack()
          blackline = canvas.create_line (0, 0, 200, 0)
          root.mainloop()
          return blackline
  </code></pre>
  
  <p>html file</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;Head&gt;
          &lt;title&gt;Line&lt;/title&gt;
      &lt;/Head&gt;
      &lt;body&gt;
         &lt;h3&gt;test&lt;/h3&gt; 
         &lt;canvas id="myCanvas" width="400" height="500"&gt;
          {{drawchart()}}
         &lt;/canvas&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>