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.
Since Chris didn't come and collect the credit, I have to answer my question myself. (But still thanks him for pointing to the right direction)
The HTML entity
stands for a NEWLINE character, and won't be interpreted in Django template. So this will work:
<textarea>{{userSetting.list | join:" "}}</textarea>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With