How to generate a line break in Django template
- by Iamamac
I want to give default value to a textarea. The code is something like this:
<textarea>{{userSetting.list | join:"NEWLINE"}}</textarea>
where userSetting.list is a string list, each item of whom is expected to show in one line.
textarea takes the content between the tags as the default value, preserving its line breaks and not interpreting any HTML tags (which means <br>,\n won't work).
I have found a solution: {{userSetting.list | join:" " | wordwrap:0}} (there is no whitespace in the list). But obviously it is NOT a good one. Any help would be appreciated.