2014-05-08 95 views
0

我無法讓我的圖像反映使用StaticFile過程。這裏是我的全局設置:Django靜態文件不同步圖像

STATIC_URL = '/static/' 
STATICFILES_DIRS = (
    ('assets', 'C:/Users/dhopkins/PycharmProjects/django_test/static'), 

我base.html文件:

{% load static %} 
<!DOCTYPE html> 
<html lang="en"> 
<head> 
<title>{% block title %}My base template.{% endblock %}</title> 
<link rel="stylesheet" type="text/css" href="{% static "assets/css/default.css" %}"> 
</head> 

<body> 
<div id="page"> 

</div> 
<div id="sidebar"> 
    {% block sidebar %} 
    <ul> 
     <li><a href="/articles/all">Articles</a></li> 
     <li><a href="/admin/">Admin</a></li> 
    </ul> 
    {% endblock %} 
</div> 
<div id="content"> 
    {% block content %}Content goes here!{% endblock %} 
    <img scr="{% static "images/python-logo.jpg" %}" width="200"/> 
</div> 
</body> 
</html> 

我的圖片文件夾位於C:\用戶\ dhopkins \ PycharmProjects \ django_test \靜態\圖像。 請幫忙。

+0

也許問題出在前綴'資產'?你可以嘗試刪除它嗎? – zymud

+0

通過刪除'資產'它也沒有檢測到CSS。通過刪除它,Css設置不會在模板上反映出來。 – user3114321

回答

1

你的問題就出在這行

<img scr="{% static "images/python-logo.jpg" %}" width="200"/> 

應該

<img src="{% static "images/python-logo.jpg" %}" width="200"/> 

這是不是與你的靜態文件有問題。你只是拼錯<img src>屬性:-)

+0

謝謝......它的工作! – user3114321