Images and Css not showing on django production

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 your alias or root directive in nginx.
  • Your STATIC_URL needs to correspond to the location 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:

Also, if you do a search through the deployment section for nginx, you’ll find a number of other working examples.

1 Like