django路由

静态文件配置

1、项目下面新建一个文件夹static

settings.py中最后添加

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static")
]
View Code

2、目录结构:

static

  my_demo1

    timer.js

timer.js

$("h4").click(function () {
    $(this).css('color', 'red');
});
View Code

timer.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/static/jquery-1.4.4.min.js"></script>

</head>
<body>
    <h4>{{ ctime }}</h4>

</body>
<script src="/static/my_demo1/timer.js"></script>

</html>
View Code

猜你喜欢

转载自www.cnblogs.com/fmgao-technology/p/9453389.html