Static and Media when deployed

When considering static and media files in the context of deployment there are a few options available depending on where you are choosing to deploy.

An excellent start for static files is to use the Whitenoise package which handles pretty much everything you need.

The other more complex options include the following:

  1. If you are using a plain linux VPS or similar, then you can configuring nginx/apache/caddy to serve the static files
  2. You can use django-storages to configure object storage like S3 or Cloudflare R2. This is essential if you are using a PaaS such as render, heroku or fly otherwise you will lose data at some point.

When it comes to media files unfortunately there isn't a similar whitenoise package available, so the most common option these days is picking one of the solutions just mentioned. Object Storage is slightly easier to get started with if you don't want to be messing around with web server configuration, but this can depend on the existing setup.

If you need help with this then I am available for hire!