我創建了一個DJANGO博客引擎,它將我的文章和模板解析爲html標籤。鏈接等。正在工作,但它不加載圖像文件,而是顯示'替代'。我試過在單獨的html文件中的標籤,否則。只是不顯示在Django博客文章內的圖像。Django不顯示博客圖片Post
模板文件中的相關部分:
{% include 'blog/header.html' %}
</aside>
<section id ="content">
<article>
{%for post in posts %}
<h2><a href="{{ post_get_absolute_url }}">{{ post.title }}</a></h2>
<h3>{{ post.created}}</h3>
<p>
{{ post.body|safe }}<br>
</p>
<h3>By {{ post.author }}</h3>
我的複製粘貼相關帖子
<---- text here ------------------>
<a href="http://gdcm.sourceforge.net/html/classgdcm_1_1Directory.html">GDCM::Directory</a>
<img src="/home/usman/www/deejay/blog/static/images/dicomdir.png" />
This is it
有趣的是,「A」標籤工作正常,但在「IMG」標籤不工作。我已經嘗試了許多變體,但是我想要一些內聯代碼來顯示簡單的html標記,或者當然我會通過將一些變量傳遞給模板以便讓它知道圖像的位置,從而以編程方式使用它。
你應該使用'{{STATIC_URL}}'標籤。 ''只是確保您的設置已經正確調整。 https://docs.djangoproject.com/en/dev/howto/static-files/ – Ngenator