【问题标题】:django rest-framework : can't get static filesdjango rest-framework:无法获取静态文件
【发布时间】:2014-11-19 17:52:54
【问题描述】:

当我在本地主机中使用 rest-framework 时,它运行良好:

但是当我将代码放到亚马逊 EC2 并使用主管打开 port 8000wsgi.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


【解决方案1】:

运行manage.py collectstatic :)

【讨论】:

    猜你喜欢
    • 2020-08-12
    • 1970-01-01
    • 2015-08-25
    • 2022-11-05
    • 1970-01-01
    • 2012-07-14
    • 2014-07-12
    • 2021-10-03
    • 2018-03-19
    相关资源
    最近更新 更多