Package: django-yaa-settings
Yet Another App Settings - manage settings for your reusable appProject site:http://radiac.net/projects/django-yaa-settings/Source code:https://github.com/radiac/django-yaa-settingsFeaturesEasy to install and useProvide defaults and validate user settings before useWorks with Django’s settings overrides in testsSupports Django 2.2 to 3.1 on Python 3.5 to 3.8.Version 1.0.0 was the last version to support earlier versions of Django.InstallationInstall from pip:pip install django-yaa-settingsUsageIn your app, create a localapp_settings.py:from yaa_settings import AppSettings

class MySettings(AppSettings):
    prefix = 'MYAPP'

    # Can be overridden in Django settings as MYAPP_ATTRIBUTE
    ATTRIBUTE = 'a static value defined at class creation'

    @property
    def PROPERTY(self):
        """
        Return a value calculated whenever it is accessed

        Can be overridden in Django settings as MYAPP_PROPERTY
        """
        return 'a value calculated when accessed'

    def CALLABLE(self, value):
        """
        Always called, passed the MYAPP_CALLABLE value from Django settings
        (or passed None if that is not defined)
        """
        if value is None:
            raise ValueError('MYAPP_CALLABLE must be configured')
        return valueImport and subclassAppSettingsOnly define oneAppSettingssubclass per fileSet theprefixattribute if you want to give your settings a prefix in
Django’s settings.Settings should be uppercase for consistency with main Django settings.Now you can access your app’s settings directly on the class, without the
prefix:from . import app_settings

def some_method(request):
    if app_settings.ATTRIBUTE == 1:
        return app_settings.PROPERTY
    return app_settings.CALLABLEYou can override these settings in your main Django settings, using the
prefix:MYAPP_ATTRIBUTE = 'value available as app_settings.ATTRIBUTE'
MYAPP_PROPERTY = 'value available as app_settings.PROPERTY'
MYAPP_CALLABLE = 'value passed to MySettings.CALLABLE'Why?Use theprefixto namespace your settingsIt’s always a good idea to namespace your settings based on your app’s name to
avoid collisions with other apps. By using theprefixattribute you can
omit the prefix throughout your app, making your code neater.The prefix is optional and you can manually namespace your settings if you’d
prefer the consistency of using the same full setting throughout your project.Namespace settings while retaining test supportUsing theprefixmimicks the simplersettings.pythat you find in some
projects:from django.conf import settings
SETTING = getattr(settings, 'MYAPP_SETTINGS', 'default')but unlike that simpler pattern, Yaa-Settings still works with standard setting
overrides for tests - see theDjango documentationfor more details.Create dynamic defaults using propertiesA property on yourAppSettingssubclass will be evaluated every time you
access it, unless you override it in Django’s settings. This allows you to
generate dynamic defaults at runtime.Validate or standardise settings using methodsA method on yourAppSettingssubclass will be called every time you access
it, and will be passed the value you have defined in Django’s settings. This
allows you to validate settings, or process them ready for use.Changelog1.1.0, 2020-07-22: Moved supported Django to 2.2 to 3.1 (#1, #2 - thanks to clinoge)1.0.0, 2018-06-24: Released as stable0.1.0, 2018-06-24: Initial release