Reputation: 379
I am getting the lines from the linux
log files and i am displaying in the bowser using django.
<pre> lines </pre>
but then my html tags are not rendered properlyis there any way to display that in good format with newlines and html tag rendered properly
Upvotes: 0
Views: 407
Reputation: 383
You can try to convert newlines to <br />
tags
There is a Django filter that can be useful https://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
{{ value|linebreaks }}
Upvotes: 0
Reputation: 53326
Try using linebreaks
or linebreakbr
filters. From django reference
linebreaks
Replaces line breaks in plain text with appropriate HTML; a single newline becomes an
HTML line break (<br />) and a new line followed by a blank line becomes a paragraph
break (</p>).
For example:
{{ value|linebreaks }}
If value is Joel\nis a slug, the output will be <p>Joel<br />is a slug</p>.
You can also use linenumbers
Upvotes: 0
Reputation: 22561
You can use built-in template tags:
{{ lines|linebreaks }}
or
{{ lines|linebreaksbr }}
Upvotes: 1