[Answered ]-Using collectstatic with multiple environments

2👍

You can set the environment variable DJANGO_SETTINGS_MODULE so you don’t need specify –settings everywhere:

heroku config:set DJANGO_SETTINGS_MODULE=project.settings.prod

0👍

First, if you are going to serve static via CloudFront, you can use custom origin and always use local STATIC_ROOT. Actually it has some advantages over S3 source, eg gzip support.

Another good thing you can do is to have environment dependent settings in a separate file and then import it in settings.py, eg:

local_settings.py (not in project repository, yet you can have local_settings.py.example):

#environment dependent settings
DATABASES = { .. }
CACHES = { .. }
STATIC_ROOT = 'your_path/static'

settings.py:

import local_settings
👤Marat

0👍

I’ve just replied a similar question on Upload Media from Heroku to Amazon S3. If you customise your settings to take in account environmental vars, you can use filesystem storage backends locally and S3 storage backends when pushing to Heroku. This will collect and upload your static files when your slug is compiled.

Leave a comment