【问题标题】:Django Static Files not syncing imageDjango 静态文件不同步图像
【发布时间】:2014-06-25 11:28:48
【问题描述】:

我无法使用 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。 请帮忙。

【问题讨论】:

  • 也许问题出在前缀“资产”上?你可以尝试删除它吗?
  • 通过删除“资产”,它也不会检测到 css。 Css 设置根本不会通过删除模板来反映模板。

标签: html django python-2.7


【解决方案1】:

你的问题出在这一行

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

应该是

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

这不是您的静态文件的问题。您只是拼错了&lt;img src&gt; 属性:-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-20
    • 2018-05-23
    • 1970-01-01
    • 2020-10-21
    • 2017-03-05
    • 1970-01-01
    相关资源
    最近更新 更多