【发布时间】:2016-01-13 09:59:18
【问题描述】:
当 Debug = True 时,我的静态文件没有问题。我已经阅读了https://docs.djangoproject.com/en/1.8/howto/static-files/deployment/ 上的文档,但是当 Debug = False 时仍然无法使其工作。这些是我的设置(当 Debug = True 时工作正常):
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 命令,即
python manage.py collectstatic?
标签: django amazon-elastic-beanstalk