How it works

The simplest way to get a param value is:

from apconf import Options

opts = Options()
APP_SLUG = opts.get('APP_SLUG', 'apsl-app')

We get the APP_SLUG, with the default value ‘apsl-app’. Besides, kaio stores internally the request default value, in order to inform the management scripts. (See below).

We configure the settings through classes, using django-configurations. We can use the mixins, so that the repetitive configurations rest into the mixin, centralizing the parametrization and saving code.

Important Make sure that Settings is the last class in the class definition:

Basic app settings sample:

import os
from os.path import join

from configurations import Configuration
from django.contrib.messages import constants as messages
from kaio import Options
from kaio.mixins import (CachesMixin, DatabasesMixin, CompressMixin, LogsMixin,
                         PathsMixin, SecurityMixin, DebugMixin, WhiteNoiseMixin)

opts = Options()

class Base(CachesMixin, DatabasesMixin, CompressMixin, PathsMixin, LogsMixin,
           SecurityMixin, DebugMixin, WhiteNoiseMixin, Configuration):
    Project settings for development and production.

    DEBUG = opts.get('DEBUG', True)


    BASE_DIR = opts.get('APP_ROOT', None)
    APP_SLUG = opts.get('APP_SLUG', 'test-project')
    SITE_ID = 1
    SECRET_KEY = opts.get('SECRET_KEY', 'key')

    USE_I18N = True
    USE_L10N = True
    USE_TZ = True
    LANGUAGE_CODE = 'es'
    TIME_ZONE = 'Europe/Madrid'

    ROOT_URLCONF = 'main.urls'
    WSGI_APPLICATION = 'main.wsgi.application'



Using mixins, almost we have only to configure the INSTALLED_APPS. For further configurations we’ll adding more mixins.