27👍
Use linebreaks
or linebreaksbr
filter:
{{ text|linebreaks }}
Or surround the text with <pre>...</pre>
.
<pre>{{ text }}</pre>
3👍
I linebreaks
uses <p>
tag to convert new line, this will probally not preserve the empty line or you will just not see it due to css styling.
You can try instead linkebrksbr that will use <br/>
for new lines.
Hope this helps
0👍
Try to use <br/>
<br/>
is an HTML code. Don’t forget you are working with HTML using Django. Keeping this in mind will solve a lot of beginners trouble.
- How does django-nose differ from the default Django test-runner
- Assign Value of Named URL to a Variable in Django Templates
- How show personalized error with get_object_or_404
- Have a url that accepts all characters
0👍
<pre>
tag works fine, but has some default declarations (like monospace and margins).
The solution for me was to take the essence of the <pre>
tag – the following declaration:
white-space: pre;
And modify it (if you don’t need extra spaces):
white-space: pre-line;
Now the data from the database fields models.TextField
keep all the line breaks.
- Create a canonical "parent" product in Django Oscar programmatically
- Django __call__() missing 1 required keyword-only argument: 'manager'