How to remove html / javascript from text input in django

What is the easiest way to remove all html / javascript from a string?

+58
python django
May 18 '09 at 10:53
source share
3 answers

If you want to cut tags in python, you can use:

from django.utils.html import strip_tags strip_tags(string_value) 

EDIT: If you use strip_tags, you should update django. Because security researchers have found a way around the strip_tags. Additional information: http://www.mehmetince.net/django-strip_tags-bypass-vulnerability-exploit/

+126
May 18, '09 at 23:15
source share

Filter striptags .

 {{ value|striptags }} 
+34
May 18 '09 at 11:04 p.m.
source share

nice snippet if you want to keep multiple tags and share the rest:

http://djangosnippets.org/snippets/295/

-3
Jul 11 '11 at 11:27
source share



All Articles