Skip to main content

App Settings for Django 1.7

Project description

https://pypip.in/version/django-pods/badge.svg https://pypip.in/format/django-pods/badge.svg https://travis-ci.org/OohlaLabs/django-pods.svg?branch=master https://coveralls.io/repos/OohlaLabs/django-pods/badge.png?branch=master https://landscape.io/github/OohlaLabs/django-pods/master/landscape.png https://pypip.in/py_versions/django-pods/badge.svg https://pypip.in/license/django-pods/badge.svg

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:

  1. Dictionary style (as per Django Rest Framework):

    YOUR_APP = {
        "SETTING": "VALUE"
    }
  2. Prefix style:

    YOUR_APP_SETTING = "VALUE"

Installation

pip install django-pods

Usage in Reusable Apps

  1. Add django-pods to the install_requires of your setup.py:

    setup(
        name="rock_n_roll",
        install_requires=["django-pods", ...],
        ...
    )
  2. 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"
  3. 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"
  4. 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

  1. Install the app that uses Django Pods:

    pip install rock_n_roll
  2. Add the app to the INSTALLED_APPS of your project/settings.py:

    INSTALLED_APPS = (
        ...
        "rock_n_roll",
        ...
    )
  3. 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

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


Download files

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

Source Distribution

django-pods-1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

django_pods-1.1-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-pods-1.1.tar.gz.

File metadata

  • Download URL: django-pods-1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-pods-1.1.tar.gz
Algorithm Hash digest
SHA256 92ae9f8e6171d5eb988cf75e0529a025e3f64002f241347774b8d999bd33a7eb
MD5 f07b09e9a36a29c50e00dfaf248b1345
BLAKE2b-256 a4efd2c3a7502d66ccd006a51382be775b19229b342296f1e80d9d3f1206a43d

See more details on using hashes here.

File details

Details for the file django_pods-1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_pods-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d2346148c8500227f09f57dac660067661c542b7d33c04cf6bf94bacaeb7ab52
MD5 42676d6eefc6d37df3c82b0550418bd9
BLAKE2b-256 90aa664ce7455fc34003a32ef8440cfdcbf8988f97f13166f44f06be33f79359

See more details on using hashes here.

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