Reputation: 116
I want to display the text in HTML from Django in proper format.
i.e. Proper space, line break, etc.
I used <p>{{blog.main_content}}</p>
This is the screenshot of data added
The text displaying in webpage
Please help me to figure it out. How can I display this text in a proper format?
Upvotes: 0
Views: 1118
Reputation: 396
You did not share how it is saved in the database. Assuming it is a plain text save. You can use the linebreaks
filter.
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
{{blog.main_content|linebreaks}}
Upvotes: 2