With Django, is it possible for users to submit HTML in a form field, save it, and then render the HTML in the template?
An example is a user adding a link within a textfield that should then be rendered as an a tag within the rest of the text.
The user would input something like :
this is a site called <a href="http://stackoverflow.com">SO</a>.
The SO link would be a link instead of rendering it as text.
Django escapes by default. You can mark a string as
safevia a filter or tag to prevent the auto escaping behavior.If you accept user inputted html, you’ll want to sanitize it so they can’t write scripts and such.. for that, just search python html sanitizing and apply it before sending the data to the template.
Python HTML sanitizer / scrubber / filter