title: Insert python string into Django template context with markup
body: <p>If I render a static image in the .html template it works. But if I provide the static markup string as dictionary value to the template (the context), it will not work. It seems to be something to do with string formatting and not allowing me to use {% %} the way I need to. I have tried:<br>
  1. .format()<br> 
  2. escaping the percent characters<br>
  3. raw strings<br>
  4. concatenation<br>
  5. autoescape<br>
  6. | safe<br>
  and a number of other things<br></p>
  
  <p>Basically, I am constructing a multi-line string in view.py with '''{% %}''', and then rendering a template with this string as the context. Python 2.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Simple non-working example:</p>
  
  <p>view.py</p>
  
  <pre><code>def index(request):
      image_insert = ''
      images = ['image1.jpg', 'image2.jpg', 'image3.jpg']
      for image in images:
          image_insert += '&lt;img src="{}"&gt;'.format(image)
      context = {'insert': image_insert}
      template = loader.get_template('index.html')
      return HttpResponse(template.render(context, request))
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>{% load static %}
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Basic HTML File&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      First Image
      &lt;img src={% static "image.jpg" %}&gt;
      Second Image  &lt;!-- does not work --&gt;
      {{ image_insert | safe }}
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Page Source:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Basic HTML File&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;img src=/static/mqdefault.jpg&gt;
      Second Image
      &lt;img src="image1.jpg"&gt;&lt;img src="image2.jpg"&gt;&lt;img src="image3.jpg"&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Obviously, there is a difference. This is Django 1.11 btw if it makes a difference.</p>