python - How to put html in django template variables? -
i want put in pieces of html in template variables. this:
>>>t = django.template.template("<ul>{{ title }}<\ul>: {{ story }}") >>>c = django.template.context({"title":"this title",r"line 1.<br />line 2."}) >>>print t.render(c) <ul>this title<\ul>: line 1.<br />line 2.
i expected output this:
<ul>this title<\ul>: line 1.<br />line 2.
how can put in html within template variables?
use safe filter, e.g.:
t = django.template.template("{{ title|safe }}<\ul>: {{ story|safe }}")
Comments
Post a Comment