Home:ALL Converter>Django Elasticbeanstalk: Cannot access static files when Debug = False

Django Elasticbeanstalk: Cannot access static files when Debug = False

Ask Time:2015-10-15T12:54:36         Author:gumbynr

Json Formatter

My static files are served with no issue when Debug = True. I have read the documentation on https://docs.djangoproject.com/en/1.8/howto/static-files/deployment/ but still cannot get it to work when Debug = False. These are my settings (works fine when 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"),                 
)

I have edited the config file to be:

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/"

I have been banging my head on this for some time so any help would be much appreciated!

Author:gumbynr,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/33140147/django-elasticbeanstalk-cannot-access-static-files-when-debug-false
Shannon Chan :

collectstatic command would have collected all your static file to STATIC_ROOT which you had set as \"/PATH/TO/myapp/static/static-only.\n\nSo I suspect that you pointed your static files to the wrong directory in the config file. \n\nTry \"/static/\": \"myapp/static/static-only\"",
2015-10-16T18:48:32
yy