Jason Howard
Jason Howard

Reputation: 1586

Adding linebreaks to string and then rendering linebreaks

I'm attempting to build a linebreak into a string and then render that string in a template with the linebreaks. I'm saving the following string to a model field:

usercart.other_tax_regnum = "State tax reg number" + "/n" + "Second State tax reg number"  
usercart.save()

Then, within my view, I render thefield

 {{ usercart.other_tax_regnum|linebreaks }}

Rather than showing a line break, this is what gets rendered:

State tax reg number/nSecond State tax reg number

Any thoughts on how I can do this?

Thank you!

Upvotes: 1

Views: 53

Answers (1)

Navid Zarepak
Navid Zarepak

Reputation: 4208

You made a little mistake:

Right:

\n

Wrong:

/n

There is also different ways:

Take a look here

Upvotes: 1

Related Questions