Django静态文件不同步图像

时间:2014-05-08 07:35:35

标签: html django python-2.7

我无法使用StaticFile进程反映我的图像。以下是我的全局设置:

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:\ Users \ dhopkins \ PycharmProjects \ django_test \ static \ images中。 请帮忙。

1 个答案:

答案 0 :(得分:1)

你的问题在于这一行

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

应该是

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

这不是静态文件的问题。您只是拼错了<img src>属性: - )