Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

newline in models.TextField() not rendered in template

Tags:

newline

django

I have a model with an attribute,

desc = models.TextField() 

I entered data using admin interface provided by Django and then later viewed my template where the database values are fetched and displayed.

In my admin interface I left newline (just by leaving blank lines in between my paragraphs) but they are displayed as a single paragraph in my template.

I'm using Django 1.3 and MySQL.

like image 874
John Avatar asked Apr 22 '12 18:04

John


1 Answers

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 }}

like image 135
Ignacio Vazquez-Abrams Avatar answered Oct 07 '22 16:10

Ignacio Vazquez-Abrams