Skip to content

andres-torres-marroquin/django-system-globals

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Build Status

django-system-globals

Version 0.0.8

What

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

Installing

First of all

pip install django-system-globals

Add it to your Django Project

INSTALLED_APPS on settings.py

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

additionally you can add it to TEMPLATE_CONTEXT_PROCESSORS

TEMPLATE_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}

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages