D
D
DjangoIsFree2014-09-28 23:38:00
Django
DjangoIsFree, 2014-09-28 23:38:00

How to "embed" a string that contains HTML tags into a template?

For example, there is a model

class Post(models.Model):
   body = models.TextField()

and its content:
Post.body = "<p><strong>Hello, world</strong></p>"
I'm passing the object to the template:
<html>
    <body>
         {{ Post.body }}
    </body>
</html>

Naturally, the entire line is displayed along with HTML tags, but it is necessary that these tags are "embedded" in this template and the final markup of the template is:
<html>
    <body>
         <p><strong>Hello, world</strong></p>
    </body>
</html>

in what way it can be implemented?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2014-09-29
@DjangoIsFree

1 thousand
2 tyks
But on the "introduced" the brain is still breaking. What is the meaning behind this word? Now I understand how:
- I need to output a line, it outputs it. But I want to get in.

A
Alexey Bukin, 2014-09-29
@abukin

That is why no one reads Of. documentation?
https://docs.djangoproject.com/en/1.7/ref/template...
P/S In Russian : djbook.ru/rel1.6/ref/templates/builtins.html
about that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question