django lookup dict是一个django应用程序,它允许您使用django模型python dict方式
django_lookup_dict的Python项目详细描述
一个django应用程序,允许您使用该应用程序创建的djanog模型和类似python dict的操作符。用于存储配置变量
你好,世界
简单演示:
from django_lookup_dict import LookupDict lookup = LookupDict() lookup['hello'] = 'world' print "Lookup for Hello is : {0}".format(lookup['hello'])
如何:
设置值,使用方括号运算符进行常规赋值[]:
lookup['hello'] = 'world'
使用方括号运算符[]检索值:
lookup['hello']
密钥计数:
len(lookup)
deletin,使用del和方括号运算符:
del lookup['hello']
删除某些键:
# lookup.delete(*args) lookup.delete('key1', 'key2', 'key3')
安装
自动安装:
pip install django_lookup_dict
手动安装:从GitHub下载最新的源代码。
tar xvzf django_lookup_dict-[VERSION].tar.gz cd django_lookup_dict-[VERSION] python setup.py build sudo python setup.py install
安装后:
- Add ‘django_lookup_dict’ to INSTALLED_APPS in your django project’s settings.
- Run ‘python manage.py syncdb’ in order to create the data storage for the model.