Django默认开启自动转义:
为了防止有些人用HTML代码破坏网页
views.py文件:
from django.shortcuts import render
def index(request):
context = {
“info”:“百度”
}
return render(request,‘index.html’,context=context)
index.html文件:
Title {{ info }}
关掉自动转义:
Title {% autoescape off %} {{ info }} {% endautoescape %}
百度