Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I advise against using different settings files for different environments in favour of customising your settings with environment variables. This allows you by default to use your local development settings and override it in production. </p> <p>For example database and static / media root settings</p> <pre><code># Default database URL is a local SQLite instance DATABASE_URL = 'sqlite:///%s' % os.path.join(os.path.dirname(__file__), 'db.sqlite') DATABASES = { 'default': dj_database_url.config('DATABASE_URL', default=DATABASE_URL), } MEDIA_ROOT = os.environ.get('MEDIA_ROOT', os.path.join(os.path.dirname(__file__), 'media')) MEDIA_URL = os.environ.get('MEDIA_URL', '/media/') STATIC_ROOT = os.environ.get('STATIC_ROOT', os.path.join(os.path.dirname(__file__), 'static')) STATIC_URL = os.environ.get('STATIC_URL', '/static/') </code></pre> <p>This allows you to set any setting on Heroku via <code>heroku config:set</code> and removes the complexity of dealing with multiple settings files, for example:</p> <pre><code>heroku config:set MEDIA_URL=http://custom-media-server.com/media/ heroku config:set STATIC_URL=http://custom-media-server.com/static/ </code></pre> <p>I have also created a custom <a href="https://github.com/caffeinehit/django-project-template" rel="nofollow">Django project template</a> that can take most settings from environment variables. </p> <p>You should also look at the <a href="http://www.12factor.net/" rel="nofollow">12 Factor Application</a> website and specifically at how to <a href="http://www.12factor.net/config" rel="nofollow">store configuration</a>. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload