First, managing static files in a production environment is completely different than managing them in development.
You want to forget everything you’ve done in development - it just doesn’t apply, and relying upon that information is not useful. You also don’t want to make references to that information here, it doesn’t help.
Briefly:
- Do not server static files from within your project. Pick an “nginx-friendly” location as the desired target of those files.
- Ensuring permissions are correct is critical.
- Your
STATIC_ROOT
needs to correspond to the path you specify in either youralias
orroot
directive in nginx. - Your
STATIC_URL
needs to correspond to thelocation
directive.
The docs at How to deploy static files | Django documentation | Django provide a summary. Also, this is a topic that has been talked about a lot here. For some examples, see:
- Safe Folder Permissions Structure for Django with mod_wsgi
- Minimal docs for how-to deploy django to production.
- Django and Nginx permission issue on Ubuntu
- CSS files not loading
Also, if you do a search through the deployment section for nginx, you’ll find a number of other working examples.