본문 바로가기

Django

django / template에 html 태그 적용

<Built-in template tags and filters>

 

django 사용 중 html파일을 서버에서 받아서 template에서 보여줘야하는 상황인데 

자꾸 태그가 <br><br>안녕<br><br> 이런식으로 그대로 노출되는 상황이 발생

 

 

 

해당 문제를 해결하기 위한 방법 

 

template에 html 태그 적용하기 

 

{% autoescape off %}

  사용할 내용 넣기 
{% endautoescape %}

 

<tr>
  <th>기타</th>
  <td>
      {% autoescape off %}
      	{{ etc }}
      {% endautoescape %}
  </td>
</tr>

 

 

참고사이트

https://docs.djangoproject.com/en/3.2/ref/templates/builtins/

반응형