Woo*_*Moo 0 python django jquery pip
跟着这里
我成功跑了:
pip install django-static-jquery==2.1.4
Run Code Online (Sandbox Code Playgroud)
但是,我无法正确地在Django中获取静态内容.我有一个简单的html页面:
<html>
{% load staticfiles %}
{% static 'static_jquery/js/jquery.js' %}
</html>
Run Code Online (Sandbox Code Playgroud)
每个网页.所有最终发生的事情都是我的HTML只是吐出这个:
/static/static_jquery/js/jquery.js
Run Code Online (Sandbox Code Playgroud)
而不是实际加载库.我正在使用默认的Django推出,所以我很好奇我在这个过程中缺少的是什么.
settings.py:
INSTALLED_APPS = ( ...
django_static_jquery,
)
Run Code Online (Sandbox Code Playgroud)
包括只是'jquery'不能像其他问题中提出的那样工作.
实际上,{% static %}仅用于输出URL.如果要加载javascript文件,只需执行以下操作:
<html>
<head>
<script type="text/javascript" src="{% static 'static_jquery/js/jquery.js' %}"></script>
</head>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
419 次 |
| 最近记录: |