Created
February 18, 2017 04:19
-
-
Save sjkingo/37498c956fc7f830d751641636cb4209 to your computer and use it in GitHub Desktop.
Suppress Django deprecated warnings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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