Django: allow line break from textarea input

How do I allow line breaking in textarea input in django to later show this input on page?


Solution 1:

linebreaks

Replaces line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (<br />) and a new line followed by a blank line becomes a paragraph break (</p>).

For example:

{{ value|linebreaks }}

If value is Joel\nis a slug, the output will be <p>Joel<br />is a slug</p>.

Solution 2:

Don't use {% autoescape off %} ! Otherwise user controlled input may not get escaped, which is a security risk. As mentioned use linebreaks or linebreaksbr.