Django - 使用django-audiofield模板显示的静态文件错误

时间:2015-10-14 20:50:28

标签: python django django-templates

我一直试图在我的应用中设置功能来上传音频文件,并让它们通过前端播放。但是,当尝试使用标准Django语法{{ work.audio_file_player|safe }}在前端加载音频文件时,我收到插件包含的所有静态文件的404错误。

GET http://127.0.0.1:8000/audiofield/page-player/css/page-player.css [HTTP/1.0 404 NOT FOUND 7ms]
GET http://127.0.0.1:8000/audiofield/flashblock/flashblock.css [HTTP/1.0 404 NOT FOUND 17ms]
GET http://127.0.0.1:8000/audiofield/script/soundmanager2.js [HTTP/1.0 404 NOT FOUND 22ms]
GET http://127.0.0.1:8000/audiofield/page-player/script/page-player.js [HTTP/1.0 404 NOT FOUND 21ms]
GET http://127.0.0.1:8000/audiofield/page-player/script/page-player.js [HTTP/1.0 404 NOT FOUND 5ms]

据我所知,插件中包含必要的模板文件会引发这些错误:

{% load staticfiles %}
{% include "common_audiofield.html" %}

settings.py中的静态文件设置如下所示:

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(ROOT_PATH, "static/"),
)

我根据需要运行sudo python manage.py collectstatic,我构建的网站部分的静态文件(css,图像等)似乎加载没有问题。可能导致这种情况的任何想法,或者我如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

在settings.py中定义STATIC_ROOT并尝试:

python manage.py collectstatic