Replace comma by newline using django

I am using django and python.

I am passing post from views and I am displaying destination as {{post.destination}} using django template. If the database value for destination is "Shakespeare,Edison,Fleming" I need to replace ',' by new line.

Anyone help me.

Answers


There is not one step solution for this.

What you can do is, in your view make a string replacing ',' with '\n' and use it in template to show as line breaks.

e.g.

in view:

 new_destination = post.destination.replate(',', '\n')

In template, use linebreaksbr filter which puts <br/> tag for each new line.

{{new_destination|linebreaksbr}}

Need Your Help

SpriteKit - iOS 7 - iAd Integration Error

ios objective-c ios7 sprite-kit iad

I am trying to integrate iAd with my current sprite kit project. I have scoured existing questions, most of which say adding

Java StackOverflowError while recursively building an array from a binary search tree

java binary-tree rebuild stack-overflow

I'm trying to balance a BST by first building an array (inorder) and then rebuild the entire tree from my array.