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
django-modeldict-1.3.0.tar.gz
(10.3 kB
view details)
File details
Details for the file django-modeldict-1.3.0.tar.gz
.
File metadata
- Download URL: django-modeldict-1.3.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96ebf8f7ab23e837624ddada3985f8585ddd782dded08f93c509b259bc055f55 |
|
MD5 | c731702d0dd13cc2e68592887595dda8 |
|
BLAKE2b-256 | 1e140a88578241e16105a8ac3234de5f922b4e0b453cc279e8e30dd6fbe9ddc9 |