Gray ocean
Gray ocean

Reputation: 35

How to make: 'enter' typed in the textfield result in a break in the paragraph?

I made a blog app in django. But when the user presses enter in the blog creation form it doesn't work in the database

eg. if I type,

this is 

an example blog

in the database its stored as: this is an example blog

the enter I pressed to insert a break isn't reflected in the database

Upvotes: 0

Views: 31

Answers (1)

Hybrid
Hybrid

Reputation: 7049

You can use the linebreaks filter when outputting text into your templates.

For example:

{{ blog.content|linebreaks }}

Also, you should use models.TextField() instead of models.CharField() when designing your DB models to accommodate multiple lined text.

Upvotes: 2

Related Questions