Giter VIP home page Giter VIP logo

django-system-globals's Introduction

django-system-globals

Version 0.0.2

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}

django-system-globals's People

Contributors

andres-torres-marroquin avatar

Stargazers

Cory Johns avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.