Stores a model as a dictionary
Project description
ModelDict is a very efficient way to store things like settings in your database. The entire model is transformed into a dictionary (lazily) as well as stored in your cache. It’s invalidated only when it needs to be (both in process and based on CACHE_BACKEND).
Quick example usage. More docs to come (maybe?):
class Setting(models.Model): key = models.CharField(max_length=32) value = models.CharField(max_length=200) settings = ModelDict(Setting, key='key', value='value', instances=False) # access missing value settings['foo'] >>> KeyError # set the value settings['foo'] = 'hello' # fetch the current value using either method Setting.objects.get(key='foo').value >>> 'hello' settings['foo'] >>> 'hello'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-modeldict-rc-1.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | db25de80a1f1f91df6609924cb782c3a78d5482c77ffe49f66486a4b43dc3ff5 |
|
MD5 | 5d2372d1386689f2a64ce3240906c8d1 |
|
BLAKE2b-256 | af68a10d79f38ee1aabbbb92b6f7c30e7fc8eb1badde2444c8a8d163c2a96581 |