django从view向template传递HTML字符串的时候,django默认不渲染此HTML,原因是为了防止这段字符串里面有恶意攻击的代码。

如果需要渲染这段字符串,需要在view里这样写:

from django.utils.safestring import mark_safe


pageHtml = mark_safe("<a href='{%url equip:listEquipmentCategory 1 %}'>首页</a>")
ret = {"equit_cate_list":list,"count":count,"ecform":ecform,"page":page,"pageHtml":pageHtml}
return render(request, "list_equip_category.html",ret)

相关文章:

  • 2021-11-30
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2021-08-01
  • 2021-08-11
  • 2021-06-05
  • 2021-08-17
  • 2021-12-30
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案