Chetan Rathod
Chetan Rathod

Reputation: 116

How to display text in html from Django as it is typed in textbox

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

This is the screenshot of data added

The text displaying in webpage

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

Answers (1)

JoVi
JoVi

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

Related Questions