我有一个 Django 1.4 项目,在 Python 2.7 上运行,我正在使用 Dajaxice 0.5.4.1。我已经在我的开发机器(Windows 7)上进行了设置,一切正常。但是,当我将应用程序部署到生产服务器 (Ubuntu 12.04) 时,我收到 dajaxice.core.js
的 404 错误文件,无论如何都无法解决这个问题。生产服务器使用完全相同版本的所有软件。
我的项目结构如下所示:
/myproject
/myproject/myproject-static/ <-- all the static files are here
/myproject/myproject-static/css/
/myproject/myproject-static/img/
/myproject/myproject-static/js/
/myproject/templates/
/myproject/myproject/
/myproject/main/
/myproject/app1/
/myproject/app2/
/myproject/app3/
etc.
我按照 Dajaxice 安装步骤 here并将所有内容放在其位置(在
settings.py
,˙urls.py and
base.html` 文件中)。我的
settings.py
文件也有这些值:from unipath import Path
PROJECT_ROOT = Path(__file__).ancestor(3)
STATIC_ROOT = ''
STATIC_URL = '/myproject-static/'
STATICFILES_DIRS = (
PROJECT_ROOT.child('myproject-static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'dajaxice.finders.DajaxiceFinder',
)
DAJAXICE_MEDIA_PREFIX = "dajaxice"
DAJAXICE_DEBUG = True
我有一个
Alias
我的 django.conf
中的指令看起来像这样的文件:Alias /myproject-static/ "/path/to/myproject/myproject-static/"
我做了
collectstatic
在我的生产服务器上,并将所有静态文件收集在我项目根目录的几个文件夹中。所以,现在当我查看我部署的网站时,我可以看到 CSS 已正确应用,JavaScript 工作正常,并且网站周围的导航按预期工作。一切都很好,除了 Ajax 自 dajaxice.core.js
以来完全崩溃从不包括在内。收集静态后我的项目文件夹结构如下:
/myproject
/myproject/myproject-static/ <-- all the static files are originally here
/myproject/myproject-static/css/
/myproject/myproject-static/img/
/myproject/myproject-static/js/
/myproject/templates/
/myproject/admin/ <-- folder created with 'collectstatic' command
/myproject/css/ <-- folder created with 'collectstatic' command
/myproject/dajaxice/ <-- dajaxice.core.js is located here
/myproject/django_extensions/ <-- folder created with 'collectstatic' command
/myproject/img/ <-- folder created with 'collectstatic' command
/myproject/js/ <-- folder created with 'collectstatic' command
/myproject/myproject/
/myproject/main/
/myproject/app1/
/myproject/app2/
/myproject/app3/
etc.
我在这里的静态文件做错了什么吗?
我还应该尝试什么来解决这个简单的错误?
最佳答案
您是否检查了其余 Assets dajaxice.core.js
在您的static/dajaxice
内文件夹?如果不是,该问题可能与 STATICFILES_FINDERS
的未命中配置有关。 , 检查 Installing dajaxice again
collectstatic 和 dajaxice 的另一个常见问题是使用 --link
运行第一个问题。你在使用这个选项吗?
希望这可以帮助
关于ajax - 在生产服务器上找不到 Dajaxice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14402180/