Use the linebreaksbr
filter like this:
{{ object1.file1.read|linebreaksbr }}
Pregunta
I'd like to display the content of a file file1
link to one of my object object1
.
In my view, I added object1
to the context.
In my django template, I used:
<html> [...]
{{ object1.file1.read }}
[...]
</html>
This works perfectly but let's say my file is like this:
Lorem ipsum \n
\n
This is a pretty stupid SO question, sorry\n
foo bar
It's rendered in only one line. \n
are not interpreted. What should I do? Is there some tag/filter/blackmagic I could add to do so? Moreover, what kind of characters will be eluded using {{ file.read }} to be less specific ?
Cheers guyz
Solución
Use the linebreaksbr
filter like this:
{{ object1.file1.read|linebreaksbr }}