Allow multiple paragraphs to be seen in html from a Textfield model in database?

When I tried to use “pre” tag of html, it didn’t word wrap anything. So, I want everything to remain normal except allowing the change of paragraphs to be seen in the html page. I want to add the model with textfield from the admin page. So, django forms is not required for my page. How do I solve this?

HTML is not regular text.

If you want “text” to be formatted as html from a text field, you need to include the breaks as html tags, and mark the text as “safe” - if it’s really “safe”.

Otherwise, you would need to integrate something like a rich-text editor (such as CKEditor) to give you more a “WYSIWYG” feel.

Or, you could implement a markdown text processor to allow the text to be entered using that format.

Have you tried the template “linebreaks” filter? It works pretty well in my experience. to render text from a TextField with appropriate tags, so that you can put linebreaks for paragraphs, or to transition to sub-paragraphs. Docs section

2 Likes

Thank you very much. It worked in my case!!!