路径

/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同级目录下直接导入,会找不到文件

相关文章:

  • 2022-12-23
  • 2021-04-24
  • 2022-01-17
  • 2021-09-13
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-17
  • 2022-02-13
  • 2021-05-20
  • 2022-12-23
  • 2021-07-20
  • 2021-07-09
  • 2022-01-10
相关资源
相似解决方案