title: How to display a saved,dynamically created image in django template?
body: <p>I have created a plot in a view and saved the plot as a png inside the templates folder. But when I try to display this saved image using an <code>&lt;img&gt;</code> tag in a template html file, the image is not displayed.
  Here is an image of my folder structure: 
  <a href="https://i.stack.imgur.com/p9EZc.jpg" rel="nofollow noreferrer">Folder Structure</a></p>
  
  <p>This is how I save my plot inside a view:</p>
  
  <pre><code>def result(request):
      if request.POST and request.FILES:
          mycsv=pd.read_csv(request.FILES['csv_file'])
          c=mycsv.X
          #We divide by the class height(basically) so that Xi+1-Xi=1
          x = [d / 5 for d in c]
          n=len(x)
          b=mycsv.Y
          divi=np.sum(b)
          f = [e / divi for e in b] 
          #Thus sum(f)=1, makes calculation of mean simpler
  
          #PLOTTING BEGINS
          fig = plt.figure()
          ax = plt.subplot(111)
          ax.plot(x, f)
          plt.title('Pearson Type 1 ')
          ax.legend()
          #plt.show()
          fig.savefig('polls/templates/polls/plot.png')
          context = {'n':n,}
          return render(request, 'polls/result.html', context)
      else:
          return HttpResponse("Form Not Submitted")
  </code></pre>
  
  <p>My result.html file where I try to get the image is:</p>
  
  <pre><code>&lt;h1&gt;Graph with {{n}} points&lt;/h1&gt;
  &lt;img src='./plot.png' /&gt;
  </code></pre>
  
  <p>I'm running this on my localhost, is there a problem with permissions?</p>
  
  <p>I've just started learning django and wanted to test this thing. Thank you for your help!</p>