title: display data in html from django
body: <p>I tried to display the data (the result return back from upload_file in views.py) in HTML from django, but it didn't show anything after clicking submit button, only jump back to the initial ui.</p>
  
  <p><strong>undex.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;head&gt;
        &lt;title&gt;Detect Pothole&lt;/title&gt;
      &lt;/head&gt;     
      &lt;body&gt;
          &lt;p&gt;upload image&lt;/p&gt;     
          &lt;form method="post" enctype="multipart/form-data"&gt;{% csrf_token %}
            &lt;input type="file" name="img" accept="image/*" onchange="loadFile(event)"&gt;&lt;/input&gt;
            &lt;img id="output"/&gt;
            &lt;script&gt; &lt;!--view selected image --&gt;
                  var loadFile = function(event) {
                      var output = document.getElementById('output');
                      output.src = URL.createObjectURL(event.target.files[0]);
                   };
            &lt;/script&gt;
            &lt;input method='POST' type="Submit" name="submit" value="submut"&gt;&lt;/input&gt;
  
          &lt;/form&gt;
          {% if submitbutton == "Submit" %}
              {% for res in result %}
              {{res}}
  
              {% endfor %}
          {% endif %}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>view.py</strong></p>
  
  <pre><code>def upload_file(request):
      submitbutton= request.POST.get("submit")
      if request.method == 'POST':
          form = UploadFileForm(request.POST, request.FILES)
          if form.is_valid():
              handle_uploaded_file(request.FILES['img'])
              result=process('a.png')  ## will return 0 or 1
              print(result)
              context= {'form': form, 'submitbutton': submitbutton,'result':result} 
              return render(request, 'index.html', context)                       
      else:   
          form = UploadFileForm()
      return render(request, 'ui.html', {'form': form})
  </code></pre>