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://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 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.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-0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

django_pods-0.2-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for django-pods-0.2.tar.gz
Algorithm Hash digest
SHA256 3bbe374963c4ed4c64014a44102694b059116fa3da2c006a2c26f572ea29b946
MD5 317422aef90947ce556822aba38f56ae
BLAKE2b-256 6cb0a995a1f232005956338ede7b868a50cafa174ccc2c32ddc95a1a5b31d44d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_pods-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 648edc65a257d45b6dac1c527e02f1b7ab0c1e51b66e3af5968d74068fb1cff2
MD5 51a51116361cc198966fcc73e1f9f2cb
BLAKE2b-256 03bfb78a734ed8b45d52a9174a8ae48d421cef7b76974d8b25814e7458748f9a

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