如何在Django中使用jQuery? [英] How to use jQuery with Django?

查看:680
本文介绍了如何在Django中使用jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣使用jQuery tablesorter ,但不知何故无法使用。
我已按照说明操作,并将jquery.js和tablesorter.js放在与我的模板相同的文件夹中(html文件所在的文件夹)。不幸的是,当试图访问.js文件时,它一直打到404,我假设这意味着文件不在正确的路径上。
有关此修复的任何想法吗?

I am interested in using the jQuery tablesorter but somehow am unable to. I have followed the instructions and have placed jquery.js and the tablesorter.js in the same folder as my templates (the folder where the html file is). Unfortunately, when trying to access the .js files, it keeps hitting a 404, which I'm assuming means that the files are not on the correct path. Any ideas for this fix?

django是否有特殊的地方放置这些js文件? (不在模板文件夹中?)

Does django have a special place to place these js files? (not in the templates folder?)

<script type="text/javascript" src="jquery-latest.js"></script> 
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type ="text/javascript">
    $(document).ready(function() 
    { 
       $("#myTable").tablesorter(); 
    } 
); 

myTable与示例中的表完全相同

The myTable is the same exact table as the one in the examples

推荐答案

通常jquery,js,css,images和大多数其他静态内容都被处理为静态文件而不是django模板。阅读管理静态文件文档

Usually jquery, js, css, images and most of other static contents are handled as static files and not as django templates. Read managing static files docs.

这篇关于如何在Django中使用jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆