﻿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
28752	django.setup() should be idempotent	pascal chambon	nobody	"Alas the ticket #27176 dealt only with the ""apps.populate"" part, but the whole setup() must be protected, else we'll always have weird side effects on duplicate calls.

Here is a testcase showing the reset of the ""django"" logger level, for example, when calling setup() multiple times.

Depending on the exact LOGGING dict (with disable_existing_loggers etc.), even the shape of the logging tree might be changed.

{{{

    def test_duplicated_setup_calls(self):
        import django, logging
        #from django.conf import settings
        #print(settings.LOGGING_CONFIG, settings.LOGGING)
        
        django.setup()
        logging.getLogger('django').setLevel(logging.DEBUG)
        assert logging.getLogger('django').level == logging.DEBUG

        django.setup()
        assert logging.getLogger('django').level == logging.DEBUG  # raises

}}}

"	Bug	new	Core (Other)	1.11	Normal				Unreviewed	0	0	0	0	0	0
