D
D
Dobryi_Mrak2020-12-21 16:20:25
Django
Dobryi_Mrak, 2020-12-21 16:20:25

How to display html in text contained in model fields in Django?

I have a candidate model. Each candidate has a bio field, I want the HTML that is written in this field to be displayed on the page.
For example, if the field contains:

<h1>Моя жизнь</h1>
Родился я в небольшом городе...
<h1>Мои суперспособности</h1>
<ul>
    <li>Читаю мысли</li>
    <li>Умею летать</li> 
</ul>

Then it displayed it as beautiful text, and not as a mixture of tags and text
class Candidat(models.Model):
    name = models.CharField(max_length=20)
    surname = models.CharField(max_length=20)
    father_name = models.CharField(max_length=20)
    bio = models.TextField()
    form = models.CharField(max_length=10)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Melnikov, 2020-12-21
@Dobryi_Mrak

Like through the "Safe" filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question