D
D
Deleting Account2019-09-15 13:23:04
Django
Deleting Account, 2019-09-15 13:23:04

Django 2. How to hide all html tags in text and still make them inactive using Django 2 tags?

I have a model that has an object of the TextField class. The fields of this class in the database can contain html tags that are used to insert links, images, select text colors, that is, you can use a text editor on the site, in my case I use the django-summernote application . But on one page, which has a block that displays the latest news, you need to hide all html tags, and at the same time make sure that they do not affect the block itself in any way. That is, so that all images, links, changes in color or text style are inactive, hidden. And it is desirable that when using the filter |truncatewords:30, hidden html tags, |truncatewords does not count as words.
Now:
5d7e0f0de8502375784242.png
Needed:
5d7e0ff246553968402361.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
szelga, 2019-09-15
@Andriy_Kosmenyuk

try https://pypi.org/project/html2text/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question