静态文件的配置和加载

# 静态文件配置
STATICFILES_DIRS = [
    os.path.join(BASE_DIR,'static'),
    os.path.join(BASE_DIR,'static1'),
    os.path.join(BASE_DIR,'static2'),
]
 
# 静态文件动态解析
    {% load static %}
    <link rel="stylesheet" href="{% static 'bootstrap-3.3.7-dist/css/bootstrap.min.css' %}">
    <script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.min.js' %}"></script>
 
加载静态资源的文件夹,要访问指定的资源,就直接在url  static/1.txt就可以直接拿到指定的资源
 
  # 令牌动态解析
  {% load static %}
  <link href="{% static 'a.txt' %}"></link>
  ```
posted @ 2022-04-03 17:55  咖喱给给啊  阅读(109)  评论(0)    收藏  举报