Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

A Django App to manage any system globals from a DB table.

Project Description

What

django-system-globals is a Django App to manage any system globals from a DB.

Installation

pip install django-system-globals

Add it to your INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'system_globals',
    ...
)

additionally you may add it to you context processors:

In Django < 1.8:

TEMPLATE_CONTEXT_PROCESSORS = (
    ...
    'system_globals.context_processors.system_globals',
    ...
)

In Django 1.8+

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'system_globals.context_processors.system_globals',
                ...
            ]
        }
    }
]

Using it

>>> from system_globals.models import SystemGlobal

# setting PI
>>> SystemGlobal.objects.set('MATH_PI', '3.1416')
>>> SystemGlobal.objects.set('MATH_E', ' 2.7182 ')

# retrieving PI
>>> SystemGlobal.objects.get_value('MATH_PI')
3.1416

# retrieving E
>>> SystemGlobal.objects.get_value('MATH_E')
2.7182

# retrieving various system globals
>>> SystemGlobal.objects.as_dict()
{'MATH_PI': 3.1416, 'MATH_E': 2.7182}

>>> SystemGlobal.objects.as_dict(coerce=False)
{'MATH_PI': '3.1416', 'MATH_E': ' 2.7182 '}

>>> SystemGlobal.objects.as_dict(to_lower=True)
{'math_pi': 3.1416, 'math_e': 2.7182}

>>> SystemGlobal.objects.as_dict(prefix='MATH_')
{'PI': 3.1416, 'E': 2.7182}

>>> SystemGlobal.objects.as_dict(prefix='math_')
{'PI': 3.1416, 'E': 2.7182}
Release History

Release History

This version
History Node

0.0.4

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-system-globals2-0.0.4.tar.gz (5.1 kB) Copy SHA256 Checksum SHA256 Source Jul 30, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting