﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16568	require_debug_false does not work as intended (backward incompatible)	Andreas Pelme	nobody	"Snip from django/conf/global_settings.py:
{{{
LOGGING = {
    ...
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.CallbackFilter',
            'callback': lambda r: not DEBUG
        }
    },
    ...
}
}}}

This does not work as intended. The callback uses the DEBUG setting that is defined in the same file -- django/conf/global_settings.py -- not in the project setting file. This configuration works when used in a project settings file - but not in the global one. The result is that callback will always return True, since DEBUG is ""always"" False in global_settings.py.

I hit this problem by not having defined LOGGING in my project settings file (since I just want everything to keep working the way it's been before). The trivial work-around is to copy/paste this into my project settings file.

Steps to reproduce:
 * Create a fresh project
 * Remove LOGGING from the generated settings.py file (to simulate an old project where LOGGING is not added)
 * Define ADMINS
 * Make sure DEBUG = True
 * Trigger an internal error
 * An email 500 is sent to ADMINS

I see a couple of ways to solve this:
 1. Remove require_debug_false from global_settings.py (since it does not work) and force everyone to copy/paste the default LOGGING snippet to their settings
 2. Fix the callback function to read the actual settings instead of global_settings, for instance like this:
 
{{{
def _require_debug_false(request):
    from django.conf import settings
    return not settings.DEBUG

LOGGING = {
    ....
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.CallbackFilter',
            'callback': _require_debug_false
        }
    },
    ....
}
}}}

I would provide a proper patch, but I have no idea for how to provide a valid test case for this."	Bug	closed	Core (Other)	dev	Release blocker	fixed		djangoproject.com@… kulala.venu@…	Accepted	1	0	0	0	0	0
