0

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!

gumbynr
  • 335
  • 3
  • 16

2 Answers2

0

I don't have a direct answer to your question, other than to ask you why are you trying to do it this way. The best practice is to move your static files to S3 or ideally, CloudFront (or another non-AWS solution).

Use django-storages-redux (https://github.com/jschneier/django-storages) to use static files from S3 for production. Google 'django s3 static' and you will find several blogs explaining the process. The documentation is here.

halfer
  • 19,824
  • 17
  • 99
  • 186
dkarchmer
  • 5,434
  • 4
  • 24
  • 37
  • This blog looks as a good one: https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/ – dkarchmer Oct 15 '15 at 05:45
0

collectstatic command would have collected all your static file to STATIC_ROOT which you had set as "/PATH/TO/myapp/static/static-only.

So I suspect that you pointed your static files to the wrong directory in the config file.

Try "/static/": "myapp/static/static-only"