6👍
You can create a .ebextension/djnago.config
in your project root dir. And code for loading static assests is below:
option_settings:
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
I used this for django 4.0 on Amazon Linux 2
0👍
For Amazon Linux 2 you should add the aws:elasticbeanstalk:environment:proxy:staticfiles
option setting to your .ebextension configs. Don’t forget to run migrate and collect static commands.
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
02_collectstatic:
command: "source /var/app/venv/*/bin/activate && python3 manage.py collectstatic"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: ebdjango.settings
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
This should work for this setup in your settings.py file
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = '/static/'
- [Django]-Saving a Pillow file to S3 with boto
- [Django]-Get coordinates from Point Django
- [Django]-Authenticate() function not working django.contrib.auth
- [Django]-Django-translation: How to translate languages
- [Django]-What is the best way to have all the timezones as choices for a Django model?
Source:stackexchange.com