Django 静态文件

1.setting,py

STATIC_URL = '/static/'          #客户端显示的URL地址 具有欺骗性
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')    #真实的物理地址

2.html

<!DOCTYPE html>
<html lang="en">

{% load staticfiles %} <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <img src="/static/image/shuaige.jpeg" alt="">
<img src="{% static 'image/shuaige.jpeg' %}"> </body> </html>

3.view

def show_pic(request):
    return render(request, 'show_pic.html')
posted on 2020-05-28 21:27  InnoLeo  阅读(91)  评论(0编辑  收藏  举报