How to generate a line break in Django template
Posted
by Iamamac
on Stack Overflow
See other posts from Stack Overflow
or by Iamamac
Published on 2010-04-12T12:16:25Z
Indexed on
2010/04/17
10:23 UTC
Read the original article
Hit count: 210
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.
© Stack Overflow or respective owner