title: Rendering test as template: {% static %} not working
body: <p>Django==3.0.6</p>
  <p>I'm trying to let an admin user use template tags.
  I mean, like this:</p>
  <p><a href="https://i.stack.imgur.com/nOqsK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nOqsK.png" alt="enter image description here" /></a></p>
  <p>The filter gets id and renders a huge picture tag.</p>
  <p><strong>views.py</strong></p>
  <pre><code>class PostDetailView(DetailView):
  
      model = Post
  
      def get(self, request, *args, **kwargs):
          self.object = self.get_object()
          post_body = &quot;{% autoescape off %}\n{% load image %}\n{% load static %}\n&quot; + self.object.body + &quot;{% endautoescape %}&quot;
          return HttpResponse(Template(post_body).render(Context())) # Breakpoint
  </code></pre>
  <p>At breakpoint (shown in the code above) post_body equals:</p>
  <pre><code>{% autoescape off %}
  {% load image %}
  {% load static %}
  &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;
  
  {{ 1|img }}
  
  &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;{% endautoescape %}
  </code></pre>
  <p>The result in the browser:</p>
  <pre><code>&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;
  
  &lt;picture&gt;
      &lt;source srcset=&quot;{% static image/1_320_1x.png %} 1x, {% static image/1_320_2x.png %} 2x, {% static image/1_320_3x.png %} 3x&quot; media=&quot;(max-width: 319.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_320_1x.webp %} 1x, {% static image/1_320_2x.webp %} 2x, {% static image/1_320_3x.webp %} 3x&quot; media=&quot;(max-width: 319.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_400_1x.png %} 1x, {% static image/1_400_2x.png %} 2x, {% static image/1_400_3x.png %} 3x&quot; media=&quot;(min-width: 320px) and (max-width: 575.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_400_1x.webp %} 1x, {% static image/1_400_2x.webp %} 2x, {% static image/1_400_3x.webp %} 3x&quot; media=&quot;(min-width: 320px) and (max-width: 575.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_540_1x.png %} 1x, {% static image/1_540_2x.png %} 2x, {% static image/1_540_3x.png %} 3x&quot; media=&quot;(min-width: 576px) and (max-width: 767.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_540_1x.webp %} 1x, {% static image/1_540_2x.webp %} 2x, {% static image/1_540_3x.webp %} 3x&quot; media=&quot;(min-width: 576px) and (max-width: 767.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_720_1x.png %} 1x, {% static image/1_720_2x.png %} 2x, {% static image/1_720_3x.png %} 3x&quot; media=&quot;(min-width: 768px) and (max-width: 991.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_720_1x.webp %} 1x, {% static image/1_720_2x.webp %} 2x, {% static image/1_720_3x.webp %} 3x&quot; media=&quot;(min-width: 768px) and (max-width: 991.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_960_1x.png %} 1x, {% static image/1_960_2x.png %} 2x, {% static image/1_960_3x.png %} 3x&quot; media=&quot;(min-width: 992px) and (max-width: 1199.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_960_1x.webp %} 1x, {% static image/1_960_2x.webp %} 2x, {% static image/1_960_3x.webp %} 3x&quot; media=&quot;(min-width: 992px) and (max-width: 1199.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_1140_1x.png %} 1x, {% static image/1_1140_2x.png %} 2x, {% static image/1_1140_3x.png %} 3x&quot; media=&quot;(min-width: 1200px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_1140_1x.webp %} 1x, {% static image/1_1140_2x.webp %} 2x, {% static image/1_1140_3x.webp %} 3x&quot; media=&quot;(min-width: 1200px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;img src=&quot;{% static %}1_720_1x.png&quot; alt=&quot;asdfasdf&quot;&gt;
  &lt;/picture&gt;
  
  &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;
  </code></pre>
  <p>In the browser generated html:</p>
  <pre><code>&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;
  
  &lt;picture&gt;
      &lt;source srcset=&quot;{% static image/1_320_1x.png %} 1x, {% static image/1_320_2x.png %} 2x, {% static image/1_320_3x.png %} 3x&quot; media=&quot;(max-width: 319.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_320_1x.webp %} 1x, {% static image/1_320_2x.webp %} 2x, {% static image/1_320_3x.webp %} 3x&quot; media=&quot;(max-width: 319.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_400_1x.png %} 1x, {% static image/1_400_2x.png %} 2x, {% static image/1_400_3x.png %} 3x&quot; media=&quot;(min-width: 320px) and (max-width: 575.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_400_1x.webp %} 1x, {% static image/1_400_2x.webp %} 2x, {% static image/1_400_3x.webp %} 3x&quot; media=&quot;(min-width: 320px) and (max-width: 575.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_540_1x.png %} 1x, {% static image/1_540_2x.png %} 2x, {% static image/1_540_3x.png %} 3x&quot; media=&quot;(min-width: 576px) and (max-width: 767.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_540_1x.webp %} 1x, {% static image/1_540_2x.webp %} 2x, {% static image/1_540_3x.webp %} 3x&quot; media=&quot;(min-width: 576px) and (max-width: 767.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_720_1x.png %} 1x, {% static image/1_720_2x.png %} 2x, {% static image/1_720_3x.png %} 3x&quot; media=&quot;(min-width: 768px) and (max-width: 991.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_720_1x.webp %} 1x, {% static image/1_720_2x.webp %} 2x, {% static image/1_720_3x.webp %} 3x&quot; media=&quot;(min-width: 768px) and (max-width: 991.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_960_1x.png %} 1x, {% static image/1_960_2x.png %} 2x, {% static image/1_960_3x.png %} 3x&quot; media=&quot;(min-width: 992px) and (max-width: 1199.98px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_960_1x.webp %} 1x, {% static image/1_960_2x.webp %} 2x, {% static image/1_960_3x.webp %} 3x&quot; media=&quot;(min-width: 992px) and (max-width: 1199.98px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_1140_1x.png %} 1x, {% static image/1_1140_2x.png %} 2x, {% static image/1_1140_3x.png %} 3x&quot; media=&quot;(min-width: 1200px)&quot; type=&quot;image/png&quot;&gt;
      &lt;source srcset=&quot;{% static image/1_1140_1x.webp %} 1x, {% static image/1_1140_2x.webp %} 2x, {% static image/1_1140_3x.webp %} 3x&quot; media=&quot;(min-width: 1200px)&quot; type=&quot;image/webp&quot;&gt;
      &lt;img src=&quot;{% static %}1_720_1x.png&quot; alt=&quot;asdfasdf&quot;&gt;
  &lt;/picture&gt;
  
  &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;p&gt;
  </code></pre>
  <p><strong>The problem:</strong>
  {% static %} didn't work. As we can see, autoescape worked, load image worked. But {% static %} is not working. What can I try next?</p>