title: Django: Return image and text to same Template simultaneously for display
body: <p>I have a method in views.py that creates an image and also creates a text string to return to a template for display. The string is dependent on the dynamically generated image, so I need the image to be created, then create the string, then return both to a view. I am not using a backend currently due to not desiring to keep photos, and strings around taking up space (user does not need it). </p>
  
  <p>Trying different things below:</p>
  
  <p>This code shows just the image correctly(without the string showing up since not returned):</p>
  
  <pre><code>response = HttpResponse(content_type='image/png')
  image.save(response, "PNG")
  return response
  </code></pre>
  
  <p>This code just displays text:</p>
  
  <pre><code>    ##return text
      response=HttpResponse()
      response.write(the_string)
      return response
  </code></pre>
  
  <p>This code doesn't quite work right as it just displays text (the PIL photo object text string instead of the image, the string is displayed correctly)</p>
  
  <pre><code>objects_to_render = {"photo":image,"string":the_string}
  return render(request, "pic_text_display.html",objects_to_render, content_type='image/png')
  </code></pre>
  
  <p>In "pic_text_display.html":</p>
  
  <pre><code>{{photo}}
  {{string}}
  </code></pre>
  
  <p>Here is the output from above:</p>
  
  <pre><code>&amp;lt;PIL.Image.Image image mode=RGBA size=512x512 at 0x7FCEA377FED0&amp;gt;
  the string
  </code></pre>
  
  <p>How can I return an image and have the string available for display in the template at the same time? I am sure there is a better way to do this than I have been...</p>
  
  <p>Note that I am not using a backend model as I am not storing the attribute, just want to create the string and image, and return both for display. I seem to be having issues as I have different content types, or don't know the right syntax.</p>
  
  <p>Thanks for the help!!</p>