'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
pythondjangoamazon-web-services">
amazon-web-servicesamazon-ec2">
amazon-ec2amazon-elastic-beanstalk">
amazon-elastic-beanstalk
Solution 1:[1]
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'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kaynan Kaynan Felipe Rodrigues |
