import config from django.conf import settings USERS_SELF_REGISTRATION = "USERS_SELF_REGISTRATION" # USERS_MAIL_VALIDATION = "USERS_MAIL_VALIDATION" # USERS_MAIL_INFORMATION = "USERS_MAIL_INFORMATION" DEFAULTS = { USERS_SELF_REGISTRATION: False, # USERS_MAIL_VALIDATION: True, # USERS_MAIL_INFORMATION: True, } def get(key): # take data from config, settings or defaults try: data = getattr(config, key) except AttributeError: try: data = getattr(settings, key) except AttributeError: data = DEFAULTS.get(key) return data