Reputation: 107
let's said that I have function
def func(request):
a="Hello, <br> this is my first app"
return render_to_response(
'home.html',
{'a':a, 'request':request},
context_instance=RequestContext(request)
)
when I load variable a in home.html as
{{a}}
I will get Hello, <br>
this is my first app ,
how to present <br>
as new line in django template ...??
Upvotes: 1
Views: 2826
Reputation: 12037
Try this:
from django.utils.safestring import mark_safe
a = mark_safe("Hello, <br> this is my first app")
Django automatically escapes any HTML in your variables, so you need to mark it as a safestring.
Keep in mind, for example, that safestring + unsafestring = unsafestring. You can read more about it here
Upvotes: 3