From 7be15ffe490a656310e4c94f2cdefe84128d5398 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 28 Jul 2015 11:35:27 -0300 Subject: [PATCH] Add hack to suppress warnings from crispy_forms Temporary. Should be reverted as soon as crispy_forms get corrected! --- sapl/settings.py | 7 +++++++ sapl/temp_suppress_crispy_form_warnings.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sapl/temp_suppress_crispy_form_warnings.py diff --git a/sapl/settings.py b/sapl/settings.py index 11a44cfa6..60b9373c3 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -11,6 +11,9 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ """ from unipath import Path +from .temp_suppress_crispy_form_warnings import \ + SUPRESS_CRISPY_FORM_WARNINGS_LOGGING + BASE_DIR = Path(__file__).ancestor(2) @@ -142,3 +145,7 @@ BOWER_INSTALLED_APPS = ( 'components-font-awesome', 'foundation-icon-fonts', ) + +# hack to suppress many annoying warnings from crispy_forms +# see sapl.temp_suppress_crispy_form_warnings +LOGGING = SUPRESS_CRISPY_FORM_WARNINGS_LOGGING diff --git a/sapl/temp_suppress_crispy_form_warnings.py b/sapl/temp_suppress_crispy_form_warnings.py new file mode 100644 index 000000000..3a2db4026 --- /dev/null +++ b/sapl/temp_suppress_crispy_form_warnings.py @@ -0,0 +1,22 @@ +import copy +import logging + +from django.utils.log import DEFAULT_LOGGING + +# hack to suppress many annoying warnings from crispy_forms +# Do remove this file and corresponding import in settings +# when crispy_forms is corrected !!! +SUPRESS_CRISPY_FORM_WARNINGS_LOGGING = copy.deepcopy(DEFAULT_LOGGING) +SUPRESS_CRISPY_FORM_WARNINGS_LOGGING['filters']['suppress_deprecated'] = { + '()': 'sapl.temp_suppress_crispy_form_warnings.SuppressDeprecated' +} +SUPRESS_CRISPY_FORM_WARNINGS_LOGGING['handlers']['console']['filters'].append( + 'suppress_deprecated') + + +class SuppressDeprecated(logging.Filter): + + def filter(self, record): + msg = record.getMessage() + return not ('crispy_forms' in msg + and 'RemovedInDjango19Warning' in msg)