Static Files Don't Work Django Elastic Beanstalk Amazon Linux 2

Issue

I have Django project on EB on Amazon Linux 2. After running the collectstatic command, I can verify that there is a staticfiles folder. But when I go to the admin, the static files return 404

Here is my config file which doesn’t work:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: backend.wsgi:application
  
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: backend.settings

  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /static/: staticfiles/

Solution

I removed the slash after the static like this and it worked:

option_settings:
  ...

  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /static: staticfiles/

Answered By – Anatol

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published