Reputation: 450
Using Django 1.11.6, python 3.6.2
Short summary: static files are collected correctly on server but only one app's sub directory is served, the admin's static files return as 404.
Running the local development server everything works as expected. After deploying to my EB instance none of the static files for the admin app load. If i run eb ssh
and look around on the server I can see the collected static folder, along with all the different app's subfolders. The files are all there where I'd expect. The links produced on the django front-end map in a sensible way to these paths, it's just that anything in static/admin returns a 404, while the files in static/entities work fine.
Testing paths on the front end:
/static/admin/css/base.css (404)
/static/entities/style.css (works)
On server, all collected files in static look fine:
/opt/python/current/app/static/admin/css
/opt/python/current/app/static/entities
No idea why one sub directory is server fine but the others return 404s.
From my django.config
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "spf.settings"
"PYTHONPATH": "/opt/python/current/app:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
"aws:elasticbeanstalk:container:python":
WSGIPath: spf/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
...
03_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"
Running the collectstatic command locally produces the correct static folder with the same subdirectories for each app too.
Upvotes: 1
Views: 2038
Reputation: 450
Sheepish self-answer here: In the AWS configuration for my eb instance I had set some static file aliases to serve directly from one of my sub apps. (Look under configuration->Software Configuration->Static Files). These aliases override any wsgi settings you may have in your django application. :)
Upvotes: 3