静态文件配置
1、项目下面新建一个文件夹static
settings.py中最后添加
STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ]
2、目录结构:
static
my_demo1
timer.js
timer.js
$("h4").click(function () { $(this).css('color', 'red'); });
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>