【发布时间】:2014-11-19 17:52:54
【问题描述】:
当我在本地主机中使用 rest-framework 时,它运行良好:
但是当我将代码放到亚马逊 EC2 并使用主管打开 port 8000 和 wsgi.ini
但它无法获取 CSS 和 JS 文件:
"NetworkError: 404 NOT FOUND - http://ec2-1-2-3-4.ap-northeast-1.compute.amazonaws.com:8000/static/rest_framework/css/bootstrap-tweaks.css"
我的 settings.py :
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
("js", os.path.join(STATIC_ROOT,'js')),
("css", os.path.join(STATIC_ROOT,'css')),
("images", os.path.join(STATIC_ROOT,'images')),
("fonts", os.path.join(STATIC_ROOT,'fonts')),
)
为什么会这样?? 请帮我!非常感谢
【问题讨论】:
-
我们可以查看您的静态文件设置吗?
-
你跑
manage.py collectstatic了吗? -
谢谢@RobAgar,manage.py collectstatic 效果很好!!
标签: python django django-rest-framework