i try it 

https://github.com/sunscrapers/djoser/blob/master/djoser/conf.py 

 user->settings.py use for settings load on global

from copy import deepcopy

from django.core.exceptions import ImproperlyConfigured
from django.conf import settings


default_settings = {
'SEND_ACTIVATION_EMAIL': False,
'SEND_CONFIRMATION_EMAIL': False,
'SET_PASSWORD_RETYPE': False,
'SET_USERNAME_RETYPE': False,
'PASSWORD_RESET_CONFIRM_RETYPE': False,
'PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND': False,
'ROOT_VIEW_URLS_MAPPING': {},
'PASSWORD_VALIDATORS': [],
'SERIALIZERS': {
'activation': 'user.serializers.ActivationSerializer',
'login': 'user.serializers.LoginSerializer',

},
'LOGOUT_ON_PASSWORD_CHANGE': False,
}


def get(key):
user_settings = merge_settings_dicts(
deepcopy(default_settings), getattr(settings, 'USER_APP', {}))
try:
return user_settings[key]
except KeyError:
raise ImproperlyConfigured('Missing settings: USER_APP[\'{}\']'.format(key))


def merge_settings_dicts(a, b, path=None, overwrite_conflicts=True):
"""merges b into a, modify a in place

Found at http://stackoverflow.com/a/7205107/1472229
"""
if path is None:
path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
merge_settings_dicts(a[key], b[key], path + [str(key)], 
overwrite_conflicts=overwrite_conflicts)
elif a[key] == b[key]:
pass # same leaf value
else:
if overwrite_conflicts:
a[key] = b[key]
else:
conflict_path = '.'.join(path + [str(key)])
raise Exception('Conflict at %s' % conflict_path)
else:
a[key] = b[key]
# Don't let this fool you that a is not modified in place
return a



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2370e781-b2a6-404e-b943-b96892b49137n%40googlegroups.com.
  • How... Lakhvinder Singh
    • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to