Skip to main content

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


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.1.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file django-modeldict-1.3.1.tar.gz.

File metadata

File hashes

Hashes for django-modeldict-1.3.1.tar.gz
Algorithm Hash digest
SHA256 2de907cf72582f2675e1357ba4c9d20afdcc3aa76022e3a5eed6e97b3d02d547
MD5 db35f2133cde3740342767dc6ab15c50
BLAKE2b-256 b28169cd0fc5f6467cf105f5d79bfbbc1690a5bd6e1be77b4fbe69657b00cdad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page