Easy Way to Escape Django Template Variables

后端 未结 6 896
礼貌的吻别
礼貌的吻别 2021-02-04 06:28

For a new project we\'re writing documentation about the Django template system. We use Django for the documentation project itself too, so Django picks up all our exam

6条回答
  •  太阳男子
    2021-02-04 06:58

    If your source is HTML, the easiest solution would be to replace "{" and "}" with their respective HTML entities:

    { becomes {

    } becomes }

    Example:

    
    To include some other file, you can use the {% include %} template tag. 
    To include a variable, use {%{% varname }%}%.
    
    

提交回复
热议问题