Here are the examples of the python api django.conf.settings._setup taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
9 Examples
3
View Complete Implementation : diffsettings.py
Copyright GNU General Public License v2.0
Author : blackye
Copyright GNU General Public License v2.0
Author : blackye
def handle_noargs(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
output = []
for key in sorted(user_settings.keys()):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
return '\n'.join(output)
3
View Complete Implementation : diffsettings.py
Copyright Apache License 2.0
Author : drexly
Copyright Apache License 2.0
Author : drexly
def handle(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
output = []
for key in sorted(user_settings):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
elif options['all']:
output.append("### %s = %s" % (key, user_settings[key]))
return '\n'.join(output)
3
View Complete Implementation : diffsettings.py
Copyright Apache License 2.0
Author : edisonlz
Copyright Apache License 2.0
Author : edisonlz
def handle_noargs(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
output = []
for key in sorted(user_settings):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
elif options['all']:
output.append("### %s = %s" % (key, user_settings[key]))
return '\n'.join(output)
3
View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_no_settings_module(self):
msg = (
'Requested setting%s, but settings are not configured. You '
'must either define the environment variable DJANGO_SETTINGS_MODULE '
'or call settings.configure() before accessing settings.'
)
orig_settings = os.environ[ENVIRONMENT_VARIABLE]
os.environ[ENVIRONMENT_VARIABLE] = ''
try:
with self.astertRaisesMessage(ImproperlyConfigured, msg % 's'):
settings._setup()
with self.astertRaisesMessage(ImproperlyConfigured, msg % ' TEST'):
settings._setup('TEST')
finally:
os.environ[ENVIRONMENT_VARIABLE] = orig_settings
3
View Complete Implementation : diffsettings.py
Copyright MIT License
Author : rizwansoaib
Copyright MIT License
Author : rizwansoaib
def handle(self, **options):
from django.conf import settings, Settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default = options['default']
default_settings = module_to_dict(Settings(default) if default else global_settings)
output_func = {
'hash': self.output_hash,
'unified': self.output_unified,
}[options['output']]
return '\n'.join(output_func(user_settings, default_settings, **options))
0
View Complete Implementation : generate_ini.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : APSL
Copyright BSD 3-Clause "New" or "Revised" License
Author : APSL
def handle_noargs(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
opts = Options()
pformat = "%-25s = %s"
puts('')
for section in opts.sections:
puts(colored.green("[%s]" % section))
for key, kaio_value in opts.items(section):
keycolor = colored.magenta(key)
if key in user_settings:
keycolor = colored.blue(key)
default_value = opts.options[key].default_value
value = kaio_value or default_value
if sys.version_info[0] < 3:
value = unicode(value).encode('utf8') # noqa: F821
else:
value = str(value)
try:
puts(pformat % (keycolor, value))
except Exception as e:
raise e
puts('')
0
View Complete Implementation : kaiosettings.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : APSL
Copyright BSD 3-Clause "New" or "Revised" License
Author : APSL
def handle_noargs(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
opts = Options()
from clint.textui import puts, colored
pformat = "%30s: %-30s %-30s %-30s"
puts('')
puts(pformat % (
colored.white('Option'),
colored.cyan('APP Value'),
colored.cyan('INI Value'),
colored.green('APP Default')))
puts('')
for section in opts.sections:
puts(pformat % (colored.green("[%s]" % section), '', '', ''))
for key, kaio_value in opts.items(section):
keycolor = colored.magenta(key)
if key in user_settings:
value = colored.green(user_settings[key])
keycolor = colored.blue(key)
else:
value = colored.green(opts.options[key].get_value_or_default())
default_value = opts.options[key].default_value
kaio_value = kaio_value if kaio_value else repr(kaio_value)
puts(pformat % (
keycolor,
clint_encode(value),
colored.white(clint_encode(kaio_value)),
clint_encode(default_value)))
puts('')
puts(colored.white("No configurables directamente en INI (estáticos o compuestos por otros):"))
puts()
not_configured = set(user_settings.keys()) - set(opts.keys())
# not_configured = not_configured - set([
# 'INSTALLED_APPS',
# 'MIDDLEWARE_CLastES',
# 'CONTEXT_PROCESSORS',
# ])
pformat = "%30s: %-50s"
puts(pformat % (
colored.white('Option'),
colored.cyan('Value')))
for key in sorted(not_configured):
if key not in default_settings:
puts(pformat % (colored.blue(key),
user_settings[key]))
elif user_settings[key] != default_settings[key]:
puts(pformat % (
colored.blue(key),
colored.green(user_settings[key])
# colored.white(default_settings[key])
))
0
View Complete Implementation : diffsettings.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
def handle(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, Settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default = options['default']
default_settings = module_to_dict(Settings(default) if default else global_settings)
output = []
for key in sorted(user_settings):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
elif options['all']:
output.append("### %s = %s" % (key, user_settings[key]))
return '\n'.join(output)
0
View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
@requires_tz_support
@mock.patch('django.conf.global_settings.TIME_ZONE', 'test')
def test_incorrect_timezone(self):
with self.astertRaisesMessage(ValueError, 'Incorrect timezone setting: test'):
settings._setup()