Django路径到javascript不起作用 [英] Django pathing to javascript doesn't work

查看:167
本文介绍了Django路径到javascript不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



由于某些原因在Django开发服务器上,JavaScript的路径只是在



目录结构是

  site 
|
appName static templates
| | |
views.py javascript appName
| |
script.js index.html

在index.html中我有

 < script type =text / javascriptsrc = .. / .. / static / javascript / script.js>< / script> 

它不起作用



如果我将script.js直接复制并粘贴到index.html中,所有功能都可以正常工作,只是路径被弄乱了。

解决方案

如何:

  src =/ static / javascript / ...

你可以看到它在Firebug网页选项卡中加载吗?


I've been trying all sorts of things and can't figure this out!

For some reason on the Django development server the paths to the JavaScript just don't work.

Directory structure is

             site
               |
 appName    static      templates
    |          |            |
 views.py  javascript    appName
               |            |
            script.js     index.html

In index.html I have

<script type="text/javascript" src=../../static/javascript/script.js></script>

And it doesn't work!

If I copy and paste the script.js directly into index.html all of the functionality works, just the pathing is messed up.

解决方案

How about:

src="/static/javascript/..."

Can you see it being loaded in Firebug net tab?

这篇关于Django路径到javascript不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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