Blog with Django (Codemy.com) - 11 escaping HTML for post

이다연·2021년 3월 8일
0

Django

목록 보기
6/33

Escaping html

by default, django escape html for security reason in your database. Hence even though you added paragraph in your text, it doesn't apply.

  1. solution: safe pipe
    {{ post.body|safe }}
  1. add p tag in your text.
  2. Snnipet showing html tags,

    Fix: home.html
    <br/>{{ post.body|slice:"100"|safe }} </li>

However, it's better to add a snnipet field in our model. (html is coming through on our snippet now)

profile
Dayeon Lee | Django & Python Web Developer

0개의 댓글