Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orlnub123/django-class-settings
Effortless class-based settings for Django.
https://github.com/orlnub123/django-class-settings
configuration django python settings
Last synced: 3 months ago
JSON representation
Effortless class-based settings for Django.
- Host: GitHub
- URL: https://github.com/orlnub123/django-class-settings
- Owner: orlnub123
- License: isc
- Created: 2018-11-13T10:00:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T08:44:41.000Z (almost 5 years ago)
- Last Synced: 2024-10-07T09:16:04.542Z (4 months ago)
- Topics: configuration, django, python, settings
- Language: Python
- Homepage: https://django-class-settings.rtfd.io/
- Size: 109 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# django-class-settings
[![pypi][pypi-image]][pypi-url]
[![django versions][django-version-image]][pypi-url]
[![python][python-version-image]][pypi-url]
[![docs][rtfd-image]][rtfd-url]
[![build][travis-image]][travis-url]
[![coverage][coverage-image]][coverage-url]
[![license][license-image]][license-url]
[![code style][code-style-image]][code-style-url]django-class-settings aims to simplify complicated settings layouts by using
classes instead of modules. Some of the benefits of using classes include:- Real inheritance
- [Foolproof settings layouts][local_settings]
- Properties
- Implicit environment variable names## Example
```bash
# .env
export DJANGO_SECRET_KEY='*2#fz@c0w5fe8f-'
export DJANGO_DEBUG=true
``````python
# manage.py
import os
import sysimport class_settings
from class_settings import envfrom 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)
``````python
# myproject/settings.py
from class_settings import Settings, envclass 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][pypi-url] with [pip][pip-url]:
```bash
pip install django-class-settings
```### Requirements
- Django 1.11+
- Python 3.5+## Resources
- Documentation: https://django-class-settings.readthedocs.io/
- Releases: https://pypi.org/project/django-class-settings/
- Changelog: https://github.com/orlnub123/django-class-settings/blob/master/CHANGELOG.md
- Code: https://github.com/orlnub123/django-class-settings
- License: [ISC][license-url][code-style-image]: https://img.shields.io/badge/code%20style-black-000000.svg
[code-style-url]: https://github.com/ambv/black
[coverage-image]: https://img.shields.io/codecov/c/gh/orlnub123/django-class-settings.svg
[coverage-url]: https://codecov.io/gh/orlnub123/django-class-settings
[django-version-image]: https://img.shields.io/pypi/djversions/django-class-settings.svg
[license-image]: https://img.shields.io/pypi/l/django-class-settings.svg
[license-url]: https://github.com/orlnub123/django-class-settings/blob/master/LICENSE
[local_settings]: https://www.pydanny.com/using-executable-code-outside-version-control.html
[pip-url]: https://pip.pypa.io/en/stable/quickstart/
[pypi-image]: https://img.shields.io/pypi/v/django-class-settings.svg
[pypi-url]: https://pypi.org/project/django-class-settings/
[python-version-image]: https://img.shields.io/pypi/pyversions/django-class-settings.svg
[rtfd-image]: https://img.shields.io/readthedocs/django-class-settings.svg
[rtfd-url]: https://django-class-settings.readthedocs.io/
[travis-image]: https://img.shields.io/travis/orlnub123/django-class-settings.svg
[travis-url]: https://travis-ci.org/orlnub123/django-class-settings