当我在我的localhost中使用rest-framework时,它运行良好:
但是,当我把我的代码放到亚马逊EC2并使用管理程序打开它port 8000
与wsgi.ini
BUT它无法获取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
:)