您的位置:首页 > Web前端 > JQuery

在django模板中添加jquery

2017-11-27 10:45 302 查看

路径

/project_name
/app_name
/templates
/index.html

/project_name
setting.py

/static
/js
jquery.js

导入方法

1.在index.html文件中引用jquery.js文件时,在index.html文件head中如下导入:

<script type="text/javascript"  src='../../static/js/jquery.js' charset="UTF-8"></script>

2.在工程目录下的setting.py中添加如下语句

STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__), '../static/').replace('\\','/'),
)

特别注意

不能放在index.html同级目录下直接导入,会找不到文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: