S
S
Sergey Nizhny Novgorod2015-12-28 08:24:03
Django
Sergey Nizhny Novgorod, 2015-12-28 08:24:03

How to pass html-css to a block in Django?

Guys, hello.
Task: I fill in the django admin panel a TextField cell, in which I specify a large text (about 2000 characters) and pass it to the template through the following command:

{% block maincontent %}
{{ stepfieldst.main_text }}
{% endblock %}

However, I need to set html-css markup in the text. Since there will be a lot of such texts, then write fields like this in the template itself:
{% block maincontent %}
<h1>{{ stepfieldst.main_text_title }}</h1>
<p>{{ stepfieldst.main_text_filed}}<p>
# и так далее
{% endblock %}

There is no opportunity.
If I try to immediately insert text from html markup into the TextField, I get something like this:
259ff4ecc3b74fa29a6aba580c94c9dd.jpg
I read the documentation, there was no such moment there. I know this is a stupid question, but I can't seem to find a solution.
Please direct me to the right path.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Klimenko, 2015-12-28
@Terras

If I try to immediately insert text from html markup into the TextField, I get this thing:

https://docs.djangoproject.com/en/1.9/ref/template...
You just need to understand very well what you are doing and be sure that you will not get injections.
for good, first rid the text of all suspicious tags https://github.com/mozilla/bleach , and then do safe on it.
there are several solutions for integrating dzhanga and bleach, but of an incomprehensible "degree of liveliness".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question