mark_safe(s)
[source]
Explicitly mark a string as safe for (HTML) output purposes. The returned object can be used everywhere a string or unicode object is appropriate.
Can be called multiple times on a single string.
For building up fragments of HTML, you should normally be using django.utils.html.format_html()
instead.
String marked safe will become unsafe again if modified. For example:
1 2 3 4 5 6 7 8 | >>> mystr = '<b>Hello World</b> ' >>> mystr = mark_safe(mystr) >>> type (mystr) < class 'django.utils.safestring.SafeBytes' > >>> mystr = mystr.strip() # removing whitespace >>> type (mystr) < type 'str' > |
Please login to continue.