Amazon Elastic Beanstalk不提供Django静态文件 [英] Amazon Elastic Beanstalk not serving django static files

查看:82
本文介绍了Amazon Elastic Beanstalk不提供Django静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在弹性beantalk上建立一个简单的django应用程序.我以为我可以确定该应用程序的静态部分,因为它可以与heroku一起使用,并且可以在手动设置的服务器上使用.在调试中,我什至还检查了静态目录中的静态文件,以简化操作.映射似乎很奇怪,因为它似乎不遵循STATIC_ROOT.

I am trying to put up a simple django app on elastic beanstalk. I thought I had the static parts of the app figured out as it works with heroku and on a server that was set up manually. In debugging I even checked in a pushed the static files in the static directory to try to simplify things. The mapping seems very strange in that it doesn't seem to follow the STATIC_ROOT.

我的相关配置: settings.py

My relevant configs: settings.py

PROJECT_ROOT = os.path.abspath(os.path.dirname(__name__))
STATIC_ROOT = os.path.join(PROJECT_ROOT,'static/')
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

urls.py

(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),

日志:

[Wed Dec 26 15:39:04 2012] [error] [client 10.29.203.20] File does not exist: /opt/python/current/app/css, referer 10.29.203.20 - - 
[26/Dec/2012:15:39:04 +0000] "GET /static/css/styles.css HTTP/1.1" 404 329 "http://" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.101 Safari/537.11"

推荐答案

我今天遇到了同样的问题,我意识到我在.ebextensions/.config文件中忘记了此选项.确保也有

I came across the same problem today, and I realized that I forgot this option in the .ebextensions/.config file. Make sure you have it too

option_settings:
  - namespace: aws:elasticbeanstalk:container:python:staticfiles
    option_name: /static/
    value: static/

这篇关于Amazon Elastic Beanstalk不提供Django静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆