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'
Metadata
Release files for django-modeldict 1.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-modeldict-1.4.1.tar.gz | 10.6 kB | Without provenance | Details |
Release files / django-modeldict-1.4.1.tar.gz
| Download URL | django-modeldict-1.4.1.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1509b7089fb202f701b947a03b67b14cef3f173b385096eb076d3ca5115d8de1
|
|
BLAKE2b-256 checksum How to use checksums |
37b74ddb0fb14f057988a4ca724ce557ab3757c5e40e07dfbf81ad50a458913b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-modeldict 1.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.