Django静态文件目录配置

参考:https://docs.djangoproject.com/en/3.0/howto/static-files/

编辑setting.py

INSTALLED_APPS = [
    ...
    'django.contrib.staticfiles',
]

...

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
<!DOCTYPE html>
<html lang="zh">
{% load static %}
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>AppBlog.CN</title>

    <link href="{% static 'layui/css/layui.css' %}" rel="stylesheet" type="text/css" />
    <script src="{% static 'layui/layui.js' %}" type="text/javascript" charset="utf-8"></script>
上一篇 Python Web框架Django模板标签
下一篇 Django POST请求报错CSRF token missing or incorrect解决
目录
文章列表
1 Android电源锁和屏幕锁帮助类
Android电源锁和屏幕锁帮助类
2
MathJax基础之对齐等式
MathJax基础之对齐等式
3
玩转Redis-干掉钉子户-没有设置过期时间的key
玩转Redis-干掉钉子户-没有设置过期时间的key
4
Spring Cloud Gateway自定义GatewayFilterFactory
Spring Cloud Gateway自定义GatewayFilterFactory
5
Prometheus + Grafana 使用 Node Exporter 监控主机
Prometheus + Grafana 使用 Node Exporter 监控主机
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。