skip to navigation
skip to content

Not Logged In

django-classsettings 1.0.1

Adds ability to define Django settings with classes/functions and navigate each of them easily

Latest Version: 1.0.2

Adds ability to define Django settings with classes.

As many text editors and IDEs indexes code symbols, with such approach you can easily navigate to any group and any line of your settings file.

Settings class

Exports defined variables into module’s scope:

from classsettings import Settings

class Administration(Settings):
    def ADMINS(self): return (
        ('Your Name', 'your_email@example.com'),
    )
    def DEBUG(self): return False
    def TEMPLATE_DEBUG(self): return self.DEBUG()

Will result in

ADMINS = (
    ('Your Name', 'your_email@example.com'),
)
DEBUG = False
TEMPLATE_DEBUG = False

Config class

Injects dictionary if variables into module’s scope:

from classsettings import Config

class REST_FRAMEWORK(Config):
    def DEFAULT_FILTER_BACKENDS(self): return (
        'rest_framework.filters.DjangoFilterBackend',
    )

Will result in

REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': (
        'rest_framework.filter.DjangoFilterBackend',
    )
}

Decorators

Some decorators may be found usefull:

from classsettings import Settings, from_env

class MySettingsGroup(Settings):
    # Will look for `EMAIL_HOST` key in `os.environ`
    # and use `smtp.gmail.com` if such key was not found
    @from_env
    def EMAIL_HOST(self): return 'smtp.gmail.com'

    # Will raise Django's `ImproperlyConfigured` exception
    # if such key was not found
    @from_env
    def SECRET_KEY(self): pass

    # Will look for specified key
    @from_env(key='CUSTOM_ENV_VAR_NAME')
    def variable(self): pass

    # Will apply `through` callable to result
    @from_env(through=dj_database_url.parse)
    def DATABASE_URL(self): return 'sqlite://'
 
File Type Py Version Uploaded on Size
django-classsettings-1.0.1.tar.gz (md5) Source 2014-03-09 3KB
  • Downloads (All Versions):
  • 0 downloads in the last day
  • 25 downloads in the last week
  • 234 downloads in the last month