Last week I started a post series exploring the
django.utils module. In this second part I will be focusing more
Returns the given text with ampersands, quotes and angle brackets encoded for use in HTML.
It will cause already escaped strings to be escaped again:
If this is a concern, use
This function is similar to str.format, but it will conditional escape all the arguments. Prefer to use it to build
small HTML fragments instead of str.format or string interpolation, as it is safer.
Safely format HTML fragments:
A wrapper of format_html, for the common case of a group of arguments that need to be formatted using the same format
Yet another example: