当我在localhost中使用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')),
)
为什么会这样? 请帮我!非常感谢你
答案 0 :(得分:10)
运行manage.py collectstatic
:)