Yesterday, I created this post: DjangoRestFramework browsable api looks different locally vs when deployed on server?
Basically, when I did python manage.py runserver
, this showed up:
But after I deployed it to AWS (eb deploy
), this is what I see when I access the site:
The answer to the post above mentioned that it is because my static files were missing. So I searched how to deploy static files on AWS and came across this tutorial: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-update-app
Under the "Create a Site Administrator" section, it mentions that in order to serve static files, I must first define STATIC_ROOT
in settings.py
(so I did: STATIC_ROOT = os.path.join(BASE_DIR, "ebdjangoapp/static/")
) and then I did eb deploy
. However, the site still looks the same as the 2nd image (without static files). I then tried doing python manage.py collectstatic
(this created the static folder with the rest_framework
directory inside it, containing the css
files etc.) and then did eb deploy
again but the site stil looks the same as the 2nd image.
How come the static files still aren't showing up?
Note, I searched around and came across this post: Django app deployment not loading static files and the answer says:
"You then need to serve settings.STATIC_ROOT
at settings.STATIC_URL
via your web server of choice, very commonly nginx as a reverse proxy behind your Apache-mod_wsgi app server."
But I have no idea how web servers (nginx, reverse proxy, Apache-mod_wsgi) works. I have a Django app I run locally with python manage.py runserver
, and I have AWS elastic beanstalk. I deploy my Django app to AWS by doing eb deploy
. What steps do I need to take in order for the static files to appear on deployment (assuming I don't know how to configure nginx, reverse proxy etc.).?