title: How to use an image generated in Javascript in a function inside my Django's view?
body: <p>I'm making an application where my view renders a template with information, then inside my template with Javascript I create a canvas element, I have the data:URI in my Javascript code, but I want to save correctly that image in my MEDIA_ROOT (supposed in /media/report directory) on my server in a Django's way, as I do in another view with a form, but this is not a form! Is a success page where render the template with information and in the same view I have a function that I need that image, maybe my problem can be a little tricky but I will put my template code and my view code to show what I want to do.
  I don't know if I'm thinking correctly. I really don't need to save that image, just need to use in the function <code>do_something_with_image()</code></p>
  <pre><code>def success(request, report_id):
      data1 = data2 = ''
  
      try:
          report = Report.objects.get(id=report_id)
  
          data1= report.data1
          data2= report.data2
  
          #picture_path is /media/report/report_id.png or the file generated in Javascript
          do_something_with_image(picture_path)
          
      except:
          messages.error(request, &quot;Error&quot;)
  
      context={
          'report_id': report_id,
          'data1': data1,
          'data2': data2,
      }
  
      return render(request, 'exito.html', context) 
  </code></pre>
  <p>Maybe I need to do a POST request?</p>
  <p>Here is my template code with the javascript code:</p>
  <pre><code>        &lt;div id=&quot;report&quot;&gt;
            {{data1}} info - info {{data2}}
          &lt;/div&gt;
          &lt;script&gt;
          
          window.onload = function() {
              //dom not only ready, but everything is loaded
              html2canvas(document.getElementById(&quot;report&quot;)).then(canvas =&gt; {
                  let image = canvas.toDataURL(&quot;image/png&quot;).replace(&quot;image/png&quot;,&quot;image/octet-stream&quot;);
                  let link = document.getElementById('link');
                  link.setAttribute('download', 'imageIWantToUse.png');
                  link.setAttribute('href',image)
              });
          };
         &lt;/script&gt;
  </code></pre>