django[template Tags]django template variables directly display HTML code related issues

Source: Internet
Author: User

django[template Tags]django template variables directly display HTML code problems
Turn

The contents of the template variable, and if it contains HTML, the Django template system will escape the output by default, such as <p> escape to &lt;p&gt; , and then display it faithfully as <p>. To solve this problem, just remove the default escape. For example, our template code is this: {{post.content}}

Now let's turn it into this:

{% autoescape off%}

{{Post.content}}

{% Endautoescape%}


A different way
Alarm_sub_types = {{Alarm_sub_types|safe}};

This article is from the "Jeff" blog, so be sure to keep this source http://zhangxz.blog.51cto.com/5490116/1569054

django[template Tags]django template variables directly display HTML code related issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.