Skip to main content

Effortless class-based settings for Django.

Project description

django-class-settings

pypi django versions python build coverage license code style

django-class-settings aims to simplify complicated settings layouts by using classes instead of modules. Some of the benefits of using classes include:

Example

# .env
export DJANGO_SECRET_KEY='*2#fz@c0w5fe8f-'
export DJANGO_DEBUG=true
# manage.py
import os
import sys

import class_settings
from class_settings import env

from django.core.management import execute_from_command_line

if __name__ == '__main__':
    env.read_env()
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
    os.environ.setdefault('DJANGO_SETTINGS_CLASS', 'MySettings')
    class_settings.setup()
    execute_from_command_line(sys.argv)
# myproject/settings.py
from class_settings import Settings, env


class MySettings(Settings):
    SECRET_KEY = env()
    DEBUG = env.bool(default=False)
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    ]
    ROOT_URLCONF = 'myproject.urls'
    WSGI_APPLICATION = 'myproject.wsgi.application'

Installation

Install it from PyPI with pip:

pip install django-class-settings

Requirements

  • Django 1.11+
  • Python 3.5+

Resources

Project details


Download files

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

Source Distribution

django-class-settings-0.2.0.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

django_class_settings-0.2.0-py3-none-any.whl (9.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