I'm using Rollbar for error tracking for my Django Application. For some reason, I'm getting errors from my localhost (in development).
Settings.py:
import rollbar
import os
THUMBNAIL_DEBUG = False
DEBUG = False
TEMPLATE_DEBUG = False
ROLLBAR = {
'access_token': '****',
'environment': 'development' if DEBUG else 'production',
'root': BASE_DIR,
'class': 'rollbar.logger.RollbarHandler'
}
rollbar.init(**ROLLBAR)
Settings_Dev.py:
from settings import *
DEBUG = True
TEMPLATE_DEBUG = True
THUMBNAIL_DEBUG = True
I use settings_dev.py for my local development environment.
I usually create three settings files. The first one is for base settings that apply to both development and production. The other two import everything from base and add extras.
So for your case, you can have settings_base.py
:
THUMBNAIL_DEBUG = False
DEBUG = False
TEMPLATE_DEBUG = False
And for settings_production.py
:
from settings_production import *
ROLLBAR = {
'access_token': '****',
'environment': 'development' if DEBUG else 'production',
'root': BASE_DIR,
'class': 'rollbar.logger.RollbarHandler'
}
rollbar.init(**ROLLBAR)
This way Rollbar will only be enabled in production.