我是django的nooby,我尝试了许多小时来获得dajaxice运行的简单示例,但我似乎没有找到寻找文件的正确方法。
我做了并重新做了安装,并试图在堆栈溢出(如这一个和这一个 )上的许多类似问题中找到答案。
我将{% dajaxice_js_import %}放在myapp_index.html的标题中,它打印如下:
<script src="/static/dajaxice/dajaxice.core.js"
type="text/javascript" charset="utf-8"></script>但是它找不到这个文件:
ImproperlyConfigured:静态文件查找器的存储后端没有有效的位置。
结果失败了:
GET /static/dajaxice/dajaxice.core.js HTTP/1.1" 500 59奇怪的是,足够多的dajax负载:
<script type="text/javascript"
src="{% static /static/dajax/jquery.dajax.core.js" %}"></script>这是我的文件夹结构:
myproject
----manage.py
----myproject
--------settings.py
--------urls.py
----myapp
--------ajax.py
--------urls.py
--------templates
------------myapp_index.html 我也不太明白为什么我们需要两个urls.py文件,但是如果我把
from django.views.generic.simple import direct_to_template然后
url(r'^$', direct_to_template, {'template': 'myapp_index.html'}),myapp的url模式。
我还尝试了不可数的文件名
python manage.py findstatic dajaxice.core.js但是不知怎么的,它没有找到dajaxice,尽管dajaxice是安装在settings.py文件中并在INSTALLED_APPS中接受的。
同样,python manage.py collectstatic也因为同样的原因而失败,但如果我理解正确,只要我在开发服务器上,我就不需要让它运行。
我想我对基本结构有一些基本的误解。:(
我正在使用预置的最新的ubuntu软件包:
django: 1.4.5,
dajaxice: 0.5.5谢谢您的提示!
下面是模板文件:
{% load static %}
{% load dajaxice_templatetags %}
<html>
<head>
<title>My base template</title>
{% dajaxice_js_import %}
<script type="text/javascript" src="{% static "/static/dajax/jquery.dajax.core.js" %}"></script>
<script type="text/javascript">
function my_js_callback(data){
alert(data.message);
}
Dajax;
Dajaxice;
</script>
</head>
...
<button onclick="Dajaxice.myproject.myapp.sayhello(my_js_callback);">Click here!</button>
页面显示,我没有Django错误,但我在Firebug中得到了这样的信息:
"NetworkError: 500 Internal Server Error - http://localhost:8000/static/dajaxice/dajaxice.core.js"这是:
ReferenceError: Dajaxice is not defined
Dajaxice;发布于 2013-05-04 20:49:33
看来你把urls.conf搞砸了。它应该包含如下内容:
url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),是吗?
此外,您的STATICFILES_FINDERS文件的settings.py部分应该包括:
'dajaxice.finders.DajaxiceFinder',https://stackoverflow.com/questions/16378621
复制相似问题