Skip to main content

Generator For Django Settings

Project description

dsgen

License

Apache License Version 2.0

Usage

a) used in a single app:

# app/settings.py
from django.test.signal import setting_changed
from dsgen.utils import DSetting

class AppSetting(DSettting):
    SETTING_NAME = 'DEMO_APP_SETTING'
    DEFAULT = {
        '': False,
    }
    def get_passthrough_fields(self):
        fields = (
            'MEDIA_ROOT',
        )
        return fields

app_setting = AppSetting()
setting_changed.connect(app_setting.signal_handler_setting_changed)

b) used in project:

# project/settings.py
import os
from dsgen.utils import DSGenerator

class ProjectSetting(DSGenerator):
    DEFAULT_JSON_FILE = 'project.json'
    default_app_list = [
        'django.contrib.auth',
        'coolapp',
    ]

_proj = ProjectSetting(
    json_path=os.getenv(
        'PROJECT_CONFIG_JSON',
        os.path.join(
            '/etc',
            'coolproject',
            ProjectSetting.DEFAULT_JSON_FILE
        )
    )
)
__dir__ = _proj.get_config_field_list
__getattr__ = _proj.get_config_value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dsgen-2.23012005.1342-py3-none-any.whl (34.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page