Yesterday, I created this post: DjangoRestFramework browsable api looks different locally vs when deployed on server?
Basically, when I did python manage.py ru
There is definitive guide about deploying a django app to AWS Elastic Beanstalk from RealPython - here it is. It has whole section about static files and how to configure it with eb and you don't need to know anything about nginx/apache etc.
Basically you should define container_commands in your eb config, these commands will be executed after application deploy is finished. For example migrate and collectstatic, so this is an example of such section in eb config file:
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python iotd/manage.py migrate --noinput"
leader_only: true
02_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python iotd/manage.py collectstatic --noinput"
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "iotd.settings"
"PYTHONPATH": "/opt/python/current/app/iotd:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
"aws:elasticbeanstalk:container:python":
WSGIPath: iotd/iotd/wsgi.py
NumProcesses: 3
NumThreads: 20
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "www/static/"
Pay attention to aws:elasticbeanstalk:container:python:staticfiles part.
And also you should define this part in your django settings file:
STATIC_ROOT = os.path.join(BASE_DIR, "..", "www", "static")
STATIC_URL = '/static/'
I copied this example almost entirely from article above, you should really check it, it's awesome.
UPD: how to debug missing staticfiles. I usually do this (it involves sshing to your eb instance):
django.contrib.staticfiles is included in my INSTALLED_APPS./static/js/somefile.jsSTATIC_URL is the same e.g. /static/.STATIC_ROOT and check that this folder actually contains your static files in production server.option_settings section in config)Also you can try to collect static into /static dir on your production server (it's where eb looks for them by default). If all of a sudden it starts working - it means that your setting failed to override default one and you should check where else it was defined.
I hope these steps will help you to find right direction.