美文网首页
django静态文件配置

django静态文件配置

作者: 一念之间789 | 来源:发表于2018-09-27 22:21 被阅读0次

mysite2/setting.py

STATIC_URL = '/static/'
STATICDILES_DIRS =[
    os.path.join(BASE_DIR, 'static'),
]

在根目录下新建static


image.png

在book/index.html显示图片

#固定的写法
<img src="/static/book/images/pubu.jpg" alt="瀑布">

{% load static from staticfiles %}
<img src="{% static "book/images/pubu.jpg" %}" alt="瀑布">

相关文章

网友评论

      本文标题:django静态文件配置

      本文链接:https://www.haomeiwen.com/subject/cibyoftx.html