我希望我的用戶能夠編寫,例如image1並使用正則表達式來識別並用標籤替換它。我擁有了一切工作 - 但是當我把數據傳送到模板顯示我這樣做是這樣的:django render從views.py傳遞的html標籤
<div class="container">
<p>
{% articleTxt %}
</p>
</div>
ArticleTxt包含:
This is a test Article <img src="/media/articleImages/django-allauth.png">
and that was a picture and this is another one then some more text ----
original: This is a test Article *image1* and that was a picture and this is
another one *image2* then some more text
那是我的無奈。我試着改變模板:
{% autoescape off %} {{articleTXT}} {{% autoescape %}}
我也試過
{{% articleTXT|safe %}}
它總是打印標籤,而不是使它們的。無論如何,將標記嵌入從view.py傳遞到我的模板!
我不理解'articleTXT'中的whats什麼?它的'img'或'text' – Bijoy