当Debug = True时,我的静态文件没有问题。我已经阅读了关于https://docs.djangoproject.com/en/1.8/howto/static-files/deployment/的文档,但当Debug = False时仍然无法使其工作。这是我的设置(工作正常时调试=真):Django Elasticbeanstalk:当Debug = False时无法访问静态文件
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = 'myapp/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),"myapp","static","static-only")
STATICFILES_DIRS = (
os.path.join(os.path.dirname(BASE_DIR),"myapp","static"),
)
我已经编辑配置文件是:
container_commands:
collectstatic:
command: "myapp/manage.py collectstatic --noinput"
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "myapp.settings"
PYTHONPATH: "/opt/python/current/app/myapp:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "myapp/myapp/wsgi.py"
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "myapp/static/"
我一直在敲打我的头这一段时间,所以任何帮助将不胜感激!
你运行collectstatic命令,即'蟒蛇manage.py collectstatic' –
查看HTTP: //tumboverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail?rq=1 –