获取您的 自己的 Django 服务器
template.html
views.py
 
<!DOCTYPE html>
<html>
<body>

{% autoescape off %}
  <h1>{{ heading|escape }}</h1>
  <h1>{{ heading }}</h1>
{% endautoescape %}

<p>In views.py you can see what the heading variable looks like.</p>

<p>
<strong>Note:</strong>
Escaping HTML characters is a default setting in Django,
so we have to turn off autoescape in the example to see the difference.
</p>

</body>
</html>                  
from django.http import HttpResponse
from django.template import loader

def testing(request):
  template = loader.get_template('template.html')
  context = {
    'heading': 'Hello &lt;i>my&lt;/i> World!',
  }
  return HttpResponse(template.render(context, request))                    
127.0.0.1:8000/testing