django.conf.settings - python examples

Here are the examples of the python api django.conf.settings taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

3 View Complete Implementation : __init__.py
Copyright Apache License 2.0
Author : 0x0ece
def _get_oauth2_client_id_and_secret(settings_instance):
    """Initializes client id and client secret based on the settings"""
    secret_json = getattr(django.conf.settings,
                          'GOOGLE_OAUTH2_CLIENT_SECRETS_JSON', None)
    if secret_json is not None:
        return _load_client_secrets(secret_json)
    else:
        client_id = getattr(settings_instance, "GOOGLE_OAUTH2_CLIENT_ID",
                            None)
        client_secret = getattr(settings_instance,
                                "GOOGLE_OAUTH2_CLIENT_SECRET", None)
        if client_id is not None and client_secret is not None:
            return client_id, client_secret
        else:
            raise exceptions.ImproperlyConfigured(
                "Must specify either GOOGLE_OAUTH2_CLIENT_SECRETS_JSON, or  "
                " both GOOGLE_OAUTH2_CLIENT_ID and GOOGLE_OAUTH2_CLIENT_SECRET "
                "in settings.py")

3 View Complete Implementation : backend.py
Copyright BSD 2-Clause "Simplified" License
Author : django-auth-ldap
    @property
    def ldap(self):
        if self._ldap is None:
            options = getattr(django.conf.settings, "AUTH_LDAP_GLOBAL_OPTIONS", None)

            self._ldap = _LDAPConfig.get_ldap(options)

        return self._ldap

3 View Complete Implementation : conf.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
    def __init__(self):
        """
        Loads our settings from django.conf.settings, applying defaults for any
        that are omitted.
        """
        for name, default in self.defaults.items():
            value = getattr(django.conf.settings, name, default)
            setattr(self, name, value)

3 View Complete Implementation : test_fixtures_settings.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : idlesign
def test_context_manager(settings):
    from django.conf import settings as _actual_settings

    astert not _actual_settings.DEBUG

    with settings(SOME=1, DEBUG=True):
        astert _actual_settings.SOME == 1
        astert _actual_settings.DEBUG

    astert not hasattr(_actual_settings, 'SOME')
    astert not _actual_settings.DEBUG

    astert 'django.contrib.sites' in _actual_settings.INSTALLED_APPS
    astert 'django.contrib.sessions.middleware.SessionMiddleware' in _actual_settings.MIDDLEWARE
    astert 'django.contrib.sessions.middleware.SessionMiddleware' in _actual_settings.MIDDLEWARE_CLastES
    astert 'dummy' in _actual_settings.DATABASES

3 View Complete Implementation : test_models.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : ImperialCollegeLondon
    def test_models_attributes_upload_temp_default(self):
        del local_settings.UPLOAD_TMP
        default_upload_path = os.path.join(local_settings.BASE_DIR,
                                           'filepond_uploads')
        import django_drf_filepond.models
        try:
            self.astertEqual(
                django_drf_filepond.models.FILEPOND_UPLOAD_TMP,
                default_upload_path,
                'The upload temp directory in models is set to [%s] but '
                'expected it to be set to the default value [%s]'
                % (django_drf_filepond.models.FILEPOND_UPLOAD_TMP,
                   default_upload_path))
        finally:
            local_settings.UPLOAD_TMP = getattr(
                django.conf.settings, local_settings._app_prefix+'UPLOAD_TMP',
                os.path.join(local_settings.BASE_DIR, 'filepond_uploads'))

3 View Complete Implementation : django.py
Copyright MIT License
Author : kiwicom
def install(path, **kwargs):
    config = Konfig.from_object(path, strict_override=False, **kwargs)
    proxy = KonfigProxy(conf.settings, config)

    @attr.s(slots=True, hash=True)
    clast Wrapper(object):
        def __getattribute__(self, name):
            if name == "settings":
                return proxy
            return getattr(conf, name)

    load_submodules()
    sys.modules["django.conf"] = Wrapper()  # type: ignore

    _patch_settings(proxy)
    return config

2 View Complete Implementation : backend.py
Copyright BSD 2-Clause "Simplified" License
Author : django-auth-ldap
    def __init__(self, prefix="AUTH_LDAP_", defaults={}):
        """
        Loads our settings from django.conf.settings, applying defaults for any
        that are omitted.
        """
        self._prefix = prefix

        defaults = dict(self.defaults, **defaults)

        for name, default in defaults.items():
            value = getattr(django.conf.settings, prefix + name, default)
            setattr(self, name, value)

        # Compatibility with old caching settings.
        if getattr(
            django.conf.settings,
            self._name("CACHE_GROUPS"),
            defaults.get("CACHE_GROUPS"),
        ):
            warnings.warn(
                "Found deprecated setting AUTH_LDAP_CACHE_GROUP. Use "
                "AUTH_LDAP_CACHE_TIMEOUT instead.",
                DeprecationWarning,
            )
            self.CACHE_TIMEOUT = getattr(
                django.conf.settings,
                self._name("GROUP_CACHE_TIMEOUT"),
                defaults.get("GROUP_CACHE_TIMEOUT", 3600),
            )

0 View Complete Implementation : monkey_patch.py
Copyright MIT License
Author : baranbartu
def patch():
    conf.settings = OnTheFlySettings(conf.settings)

0 View Complete Implementation : middleware.py
Copyright Apache License 2.0
Author : census-instrumentation
    def __init__(self, get_response=None):
        self.get_response = get_response
        settings = getattr(django.conf.settings, 'OPENCENSUS', {})
        settings = settings.get('TRACE', {})

        self.sampler = (settings.get('SAMPLER', None)
                        or samplers.ProbabilitySampler())
        if isinstance(self.sampler, six.string_types):
            self.sampler = configuration.load(self.sampler)

        self.exporter = settings.get('EXPORTER', None) or \
            print_exporter.PrintExporter()
        if isinstance(self.exporter, six.string_types):
            self.exporter = configuration.load(self.exporter)

        self.propagator = settings.get('PROPAGATOR', None) or \
            trace_context_http_header_format.TraceContextPropagator()
        if isinstance(self.propagator, six.string_types):
            self.propagator = configuration.load(self.propagator)

        self.blacklist_paths = settings.get(BLACKLIST_PATHS, None)

        self.blacklist_hostnames = settings.get(BLACKLIST_HOSTNAMES, None)

        if django.VERSION >= (2,):  # pragma: NO COVER
            connection.execute_wrappers.append(_trace_db_call)

0 View Complete Implementation : django.py
Copyright GNU Affero General Public License v3.0
Author : maas
    def tearDown(self):
        # Reset django settings after each test since configuring Django breaks
        # tests for maascli commands which attempt to really load Django.
        django.conf.settings = django.conf.LazySettings()
        super(APIClientTestCase, self).tearDown()