App Settings for Django 1.7
Project description
Django Pods is a minimalist package that lets you configure app specific settings that can be overridden in project settings.
This package is largely inspired by Django Rest Framework and Django AllAuth and adapted to work with Django 1.7 Applications, but also with any classes extending pods.apps.AppSettings.
Installation
pip install django-pods
Django 1.7 Usage
In rock_n_roll/apps.py:
from django.apps import AppConfig from pods.apps import AppSettings class RockNRollConfig(AppSettings, AppConfig): name = 'rock_n_roll' verbose_name = "Rock ’n’ roll" # Path to app settings module settings_module = "rock_n_roll.app_settings" # Optional settings_imports = ("CLASS_TO_IMPORT",) # Optional # defaults to the capitalized class name, e.g. ROCK_N_ROLL_CONFIG settings_key = "ROCK_N_ROLL"
In rock_n_roll/app_settings.py:
QUESTION = "What is your favourite band?" ANSWER = "The Rolling Stones" CLASS_TO_IMPORT = "path.to.ClassToImport"
In project/settings.py:
ROCK_N_ROLL = { "ANSWER": "The Beatles", }
Anywhere else in your project:
from django.apps import apps app = apps.get_app_config('rock_n_roll') app.settings.QUESTION # What is your favourite band? app.settings.ANSWER # The Beatles app.settings.CLASS_TO_IMPORT # <class 'path.to.ClassToImport'>
AppSettings also implements __getattr__ to proxy to settings attributes:
app.ANSWER # The Beatles
Django < 1.7 Usage
There isn’t a logical place to create a class representing an app in Django prior to 1.7, but any class can extend AppSettings:
from pods.apps import AppSettings class AnyClass(AppSettings): settings_module = "path.to.settings" AnyClass.settings # or a = AnyClass() a.settings
Running Tests
tox
Contributions
All contributions and comments are welcome.
Change Log
v0.4
Fix bug with default settings_key not set correctly if none given
v0.3
Unit tests now use Django 1.7 final and support Django 1.6 and 1.5
Fix PyPI classifiers for supported python versions
v0.2
Fix compatibility with Django 1.6
v0.1
Initial
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-pods-0.4.tar.gz
.
File metadata
- Download URL: django-pods-0.4.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7302e87e349b3840e3ffd85cfb85b33640b5935bf38ebd8516d8b9190fb42623 |
|
MD5 | 19629245b1d10c073859837230525184 |
|
BLAKE2b-256 | b7e5e39c291f5ba7d8bfbf8de45a5bc506409d302602545297ec3e9fa163a953 |
File details
Details for the file django_pods-0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: django_pods-0.4-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21c56e80df3dee2ece66a62b1450a2a04525303ac95bdb812592b3733e4bcfef |
|
MD5 | 6624d4b571bf35e0aa7b158862722ee7 |
|
BLAKE2b-256 | 8c67f2e759a2a7655b4b47f017b04a5774c07e4a8a684203f5580fca281aadb6 |