私が欲しいのはスタックオーバーフローのようなものです。ユーザーはテキスト入力をHTML形式でフォーマットでき、ページはまったく同じ方法でレンダリングする必要があります。
フォーマットされた入力を格納するためにを使用します。文字列値をwmd.js
持つコンテキスト変数があると考えてください。テンプレートをレンダリングすると、{{variable}}
"<p>something</p>"
{{variable}} outputs <p>something</p>
and {{variable|safe}} also output <p>something</p>
ページにhtmlタグをテキストとして表示します。HTMLタグをレンダリングする{{variable}}
が、プレーンテキストとして表示しない方法。
テンプレート
<div id='thread_answer_content' >
{% for answer in question.answer_set.all %}
{{answer.answerbody|safe}}
{% endfor %}
</div>
景色
def detail(request,question_id):
q = get_object_or_404(Question,pk=question_id)
return render_to_response('CODE/detail.html',{'question':q},
context_instance = RequestContext(request)
)
これが質問のdjango管理ページです。ちなみにsqlite3を使用しています