2014-04-23 27 views
0

首先,讓我說,我是個學生努力學習Django的... 我完成我的應用程序throught教程和IM具有帶我的模板的圖像呈現出的問題,其僅僅顯示與出的圖像幀......這裏是我的html代碼:Django的靜態IMG在我的博客不會顯示

  <aside> 
       <h4>Historico</h4> 
       {% for month in months %} 
       <p><a href="{url 'blog.views.month' month.0 month.1}">{{ month.2 }}</a></p> 

       {% endfor %} 
       <h4>Sobre mi</h4> 
       <img class="pic" src="{{ STATIC_URL }}/static/img/foto.jpg" alt="foto"/> 

       <img class="picbig" src="{{ STATIC_URL }}/static/img/foto.jpg" alt="foto grande"/> 
       <p>Soy un doge san OP platino IV lan pls</p> 
      </aside> 

我的形象「foto.jpg」心不是表現,這是我的靜態

STATIC_URL = '/static/' 
STATICFILES_DIRS = (
"C:/Users/Abdul Hamid/PycharmProjects/misitioweb/static", 
) 
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder', 
'django.contrib.staticfiles.finders.AppDirectoriesFinder', 

) 

和settings.py我的IMG是這樣

的文件夾中
`C:\Users\User-Name\PycharmProjects\misitioweb\` 

`blog- 
-templtates 
--frontpage.html 
--otherthing.html 
-__init__.py 
-admin.py 
-models.py 
-test.py 
-views.py 
mysite- 
-__init__.py 
-settings.py 
-urls.py 
-wsgi.py 
manage.py 
-etc.. 
static- 
--img 
---foto.jpg 
` 

我一直在試圖改變在diferent ressults img標籤的代碼一樣裝載的靜態文件夾放到這樣的模板: {{from static import staticfiles}}

即時做錯了什麼,我已經tryied尋找更多的信息,但沒有任何工作...請幫助我! 無論如何 感謝您的時間

+0

你應該去通過官方Django的教程。這很好,不長,也很容易理解。我不是要告訴你,但你會在這裏找到答案:https://docs.djangoproject.com/en/1.6/intro/tutorial01/ – skzryzg

回答

1

它看起來像你的src屬性是不正確的你的形象。

<img class="pic" src="{{ STATIC_URL }}/static/img/foto.jpg" alt="foto"/> 

應該

<img class="pic" src="{{ STATIC_URL }}img/foto.jpg" alt="foto"/> 

由於STATIC_URL已經採取加/靜態​​的護理/到您的網址。如果您使用調試工具在瀏覽器中,並看一看的src的形象,你可能會看到它說:「/static/static/img/foto.jpg」時,它應該是「/靜態/ IMG /照片。 JPG」

0

還要確保您已通過運行收集到的靜態圖像文件:

python manange.py collectstatic 
+0

謝謝回答!已經嘗試過,但它說這 – AbdulHamid

+0

錯誤地配置(「您正在使用靜態文件應用程序」 django.core.exceptions.ImproperlyConfigured:您正在使用staticfiles應用程序,而沒有將STATIC_ROOT設置設置爲文件系統路徑 – AbdulHamid

+0

我應該移動東西在我的static_root我settings.py – AbdulHamid