Skip to content

Instantly share code, notes, and snippets.

@sjkingo
Created February 18, 2017 04:19
Show Gist options
  • Save sjkingo/37498c956fc7f830d751641636cb4209 to your computer and use it in GitHub Desktop.
Save sjkingo/37498c956fc7f830d751641636cb4209 to your computer and use it in GitHub Desktop.
Suppress Django deprecated warnings
import logging
class SuppressDeprecated(logging.Filter):
def filter(self, record):
WARNINGS_TO_SUPPRESS = [
'RemovedInDjango110Warning'
]
# Return false to suppress message.
return not any([warn in record.getMessage() for warn in WARNINGS_TO_SUPPRESS])
import logging, copy
from django.utils.log import DEFAULT_LOGGING
LOGGING = copy.deepcopy(DEFAULT_LOGGING)
LOGGING['filters']['suppress_deprecated'] = {
'()': 'logging_utils.SuppressDeprecated'
}
LOGGING['handlers']['console']['filters'].append('suppress_deprecated')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment