having completed a django project on local development on my system, i followed the Digital Ocean tutorial to deploy a django app here Digital Ocean Django ASGI setup Tutorial.
i configured gunicorn according to the tutorials and all tests and confirmations are passed But when i loaded my site from its Public IP address the site loads without any styles or designs and no images...just as plain text (just html content)
my nginx configuration is as follows
server {
listen 80;
server_name XXX.XX.XXX.XX;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/username/projectdir/staticfiles;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
and my django Project setting is as follows (section concerning static settings)
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = BASE_DIR / 'staticfiles'
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'
# extra places to find static filed outside static folder inside installed apps
STATICFILES_DIRS = [ BASE_DIR/"static" ]
MEDIA_ROOT = BASE_DIR/"media"
can any solution be suggested. i have seen all the other related stackoverflow questions that had similar issues but their solutions did not work for me . Thanks in Advance
nginx
user does not have permission to access the folder with staticfiles. I would do thissudo chmod 777 /home/username/projectdir/staticfiles
to allow all users, including nginx, to access the staticfiles dir – Mentalism