Configure Sentry for different environments (staging, production)
<p>I want to configure Sentry in a Django app to report errors using different environments, like staging and production. This way I can configure alerting per environment.</p>

<p>How can I configure different environments for Raven using different Django settings? The <code>environment</code> variable is not listed at the <a href="https://docs.sentry.io/hosted/clients/python/advanced/#client-arguments" rel="nofollow">Raven Python client arguments docs</a>, however I can find the variable in the <a href="https://github.com/getsentry/raven-python/blob/master/raven/base.py#L188" rel="nofollow">raven-python code</a>.</p>

<p>You can use different settings for different branches. You have your main one, with all shared settings. And for develop branch you have dev.py settings and for production you have your prod.py. And while deploying your app you just specify which settings are meant to be used. If not you can also use <a href="https://github.com/gitpython-developers/GitPython" rel="nofollow">GitPython package</a>. Where you make something like this:</p>

<pre><code>if branch in ['develop']:
    DEBUG = True
    RAVEN_CONFIG = {
    'dsn': 'your_link_to_raven',
}
else:
    #some other settings
</code></pre>

python django sentry raven