【问题标题】:Django - Static file, image, wont appearDjango - 静态文件,图像,不会出现
【发布时间】:2020-11-09 01:23:32
【问题描述】:

我正在学习 django。它在我的项目开始时工作,但现在来自静态的 imgs 只是不出现。 我尝试运行collecstatic、使用STATIC_ROOT、其他图像等等。

Settings.py

STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

MEDIA_URL = '/upload/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'upload')

Home.html

{% load static %}
<img scr="{% static 'img/cart-icon.png' %}">

Files dir

【问题讨论】:

    标签: django image static


    【解决方案1】:
    {% load static %}
    <img src="{% static 'img/cart-icon.png' %}">
    

    src 不是 scr

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-25
      • 1970-01-01
      • 2012-04-30
      • 2015-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-08
      相关资源
      最近更新 更多