Search code examples
pythondjangoamazon-web-servicesamazon-ec2amazon-elastic-beanstalk

Django Deploy ElasticBeanstalk StaticFiles(JS/CSS) not loading


My Styles Are Not Loading:

settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = [BASE_DIR / 'templates/static']

MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

error eb logs:

Apr 26 06:11:06 ip-172-31-46-75 web: Not Found: /static/assets/bootstrap/css/animate.css
Apr 26 06:11:06 ip-172-31-46-75 web: Not Found: /static/assets/bootstrap/css/flex-slider.min.css
Apr 26 06:11:06 ip-172-31-46-75 web: Not Found: /static/assets/bootstrap/css/slicknav.min.css
Apr 26 06:11:06 ip-172-31-46-75 web: Not Found: /static/assets/custom/css/style.css

ETC..........

I also did in my env

python manage.py collectstatic

and

eb deploy

, it still didnt load my css/js(html is perfectly loading)

my .ebextensions:

option_settings:
    aws:elasticbeanstalk:container:python:
        WSGIPath: store.wsgi:application

Solution

  • Create a

    ststic-files.config

    File and specify the directories

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

    settings.py:

    STATIC_URL = '/static/'
    STATIC_ROOT = BASE_DIR / 'static'