Skip to content

Instantly share code, notes, and snippets.

@nabucosound
Last active February 5, 2021 08:45
Show Gist options
  • Save nabucosound/6bc20583493a8a57409c to your computer and use it in GitHub Desktop.
Save nabucosound/6bc20583493a8a57409c to your computer and use it in GitHub Desktop.
Sentry and raven in Django

Create new organization, team and project in https://getsentry.com/

Install raven, do not forget to add to requirements.txt:

pip install raven

Add raven to the list of installed apps:

INSTALLED_APPS = INSTALLED_APPS + (
    # ...
    'raven.contrib.django.raven_compat',
)

Add settings:

# Raven - Sentry
RAVEN_DSN = os.environ.get('RAVEN_DSN', '')
RAVEN_CONFIG = {
    'dsn': RAVEN_DSN,
}
SENTRY_DEBUG = env_var('SENTRY_DEBUG', False)  # Log errors when DEBUG=True

Add your DSN to .env, heroku staging and production:

RAVEN_DSN='http://[public_key]:[secret_key]@app.getsentry.com/31320'
SENTRY_DEBUG=True  # ONLY IN DEV OR STAGING!!!

Test that everything is OK:

./manage.py raven test

Documentation and resources for troubleshooting:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment