Home > Software design >  AWS ElasticBeanstalk how to upload staticfiles with django
AWS ElasticBeanstalk how to upload staticfiles with django

Time:04-28

I tried uploading staticfiles:

aws:elasticbeanstalk:enviroment:proxy:staticfiles: /static: /static

got this error in

2022-04-27 03:34:07    ERROR   "option_settings" in one of the configuration files failed validation. More details to follow.
2022-04-27 03:34:07    ERROR   Invalid option specification (Namespace: 'aws:elasticbeanstalk:enviroment:proxy:staticfiles', OptionName: '/static'): Unknown configuration setting.
2022-04-27 03:34:07    ERROR   Failed to deploy application.

ERROR: ServiceError - Failed to deploy application.

I also tried only doing

python manage.py collectstatic

and it did not work

I tried my settings.py in this way:

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

and this way(current way im utilizing):

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

CodePudding user response:

You can try following configuration which worked for me.

settings.py

DEBUG = False
STATIC_URL = '/static/'
STATIC_ROOT = 'static'

Run python manage.py collect static

Go to your root urls.py and add

from django.conf.urls import url
from django.conf import settings
from django.views.static import serve 

urlpatterns = [
    ...
    ...
    url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}), 
]

you can refer Github

  • Related