I am trying to put up a simple django app on elastic beanstalk. I thought I had the static parts of the app figured out as it works with heroku and on a server that was set up manually. In debugging I even checked in a pushed the static files in the static directory to try to simplify things. The mapping seems very strange in that it doesn't seem to follow the STATIC_ROOT.
My relevant configs: settings.py
PROJECT_ROOT = os.path.abspath(os.path.dirname(__name__)) STATIC_ROOT = os.path.join(PROJECT_ROOT,'static/') STATIC_URL = '/static/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )
urls.py
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
LOGS:
[Wed Dec 26 15:39:04 2012] [error] [client 10.29.203.20] File does not exist: /opt/python/current/app/css, referer 10.29.203.20 - - [26/Dec/2012:15:39:04 +0000] "GET /static/css/styles.css HTTP/1.1" 404 329 "http://" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.101 Safari/537.11"
Configure static files using the consoleIn the navigation pane, choose Configuration. In the Software configuration category, choose Edit. In the Static files section, enter a path for serving static files and the directory of the static files to serve into the empty row at the bottom of the list.
Using the collectstatic command, Django looks for all static files in your apps and collects them wherever you told it to, i.e. the STATIC_ROOT . In our case, we are telling Django that when we run python manage.py collectstatic , gather all static files into a folder called staticfiles in our project root directory.
Your source bundle must meet the following requirements: Consist of a single ZIP file or WAR file (you can include multiple WAR files inside your ZIP file) Not exceed 512 MB. Not include a parent folder or top-level directory (subdirectories are fine)
I came across the same problem today, and I realized that I forgot this option in the .ebextensions/.config file. Make sure you have it too
option_settings: - namespace: aws:elasticbeanstalk:container:python:staticfiles option_name: /static/ value: static/
Just so you guys know, namespace for static files in recent versions of EBS, changed to aws:elasticbeanstalk:environment:proxy:staticfiles
, like this:
option_settings: aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With