App Settings for Django 1.7
Project description
Django Pods
Django Pods is a minimalist package that lets you configure default settings for your reusable apps, and allows developers using your apps to override these defaults in their own 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.
Preview
Django Pods allows developers to customise app settings in two ways:
Dictionary style (as per Django Rest Framework):
YOUR_APP = { "SETTING": "VALUE" }
Prefix style:
YOUR_APP_SETTING = "VALUE"
Installation
pip install django-pods
Usage in Reusable Apps
Add django-pods to the install_requires of your setup.py:
setup( name="rock_n_roll", install_requires=["django-pods", ...], ... )
Add the AppSettings mixin to your AppConfig implementation 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"
Declare your default app settings in rock_n_roll/app_settings.py:
QUESTION = "What is your favourite band?" ANSWER = "The Rolling Stones" CLASS_TO_IMPORT = "path.to.ClassToImport"
Access your settings anywhere in your package:
from django.apps import apps app = apps.get_app_config('rock_n_roll') app.QUESTION # What is your favourite band? app.ANSWER # The Beatles app.CLASS_TO_IMPORT # <class 'path.to.ClassToImport'>
Settings can also be accessed directly via the class:
from rock_n_roll.apps import RockNRollConfig RockNRollConfig.QUESTION RockNRollConfig.ANSWER RockNRollConfig.CLASS_TO_IMPORT
Usage in Projects
Install the app that uses Django Pods:
pip install rock_n_roll
Add the app to the INSTALLED_APPS of your project/settings.py:
INSTALLED_APPS = ( ... "rock_n_roll", ... )
Override the app’s settings as needed:
# Dictionary style ROCK_N_ROLL = { "ANSWER": "The Beatles", } # Prefix style ROCK_N_ROLL_ANSWER = "The Beatles"
Running Tests
tox
Contributions
All contributions and comments are welcome.
Change Log
v1.1.1
Switch to Semantic Versioning
Fix issue with parse_requirements for newer versions of pip (>=6.0.0)
Fix typo in AppSettingsMeta
v1.1
Exclude tests and docs from the build
v1.0
Add support for prefix style overrides
Documentation changes
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-1.1.1.tar.gz
.
File metadata
- Download URL: django-pods-1.1.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e615dde7b32d75f3c83d06daa3b931f03410257506e53abced8ded1f23a9b4fa |
|
MD5 | 6c1f089bf7c5fa8da15dc6839d8703f1 |
|
BLAKE2b-256 | 340f22a0d38f3633260515368ea3d08b0c2feda4649d51f756b53098f4827428 |
File details
Details for the file django_pods-1.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_pods-1.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ea6482eb1bd03ebfbb0f3c79f5a648605e1f56aa03e609614d4784ba846c4f |
|
MD5 | 4a6f551cef5714383f5849fce75315ef |
|
BLAKE2b-256 | e120413da607d5c4472a81feda9e1856bc1468ac21c0485a86da3186d54c1980 |