django-readonly-model
The easiest way to create read-only models
Installation
Install using pip:
pip install django-readonly-model
Add 'readonly_model' to your INSTALLED_APPS setting:
INSTALLED_APPS = [
...
'readonly_model',
]
Example
Declare a model to read:
from django.db import models
class Directory(models.Model):
class Meta:
read_only_model = True
We can read data from the model but we cannot write:
>>> from app.models import Directory
>>> Directory.objects.count()
0
>>> Directory.objects.create(name='kg')
...
readonly_model.exceptions.ReadOnlyModel: Model 'app.models.Directory' is read-only
You cannot write but you can load data from fixtures:
$ python3 manage.py loaddata fixtures/directory.json
>>> from app.models import Directory
>>> Directory.objects.count()
3
When is it needed?
-
When you want to protect the model from accidental recording.
-
When you have some data that cannot be changed programmatically (for example, various directories).
-
When you need to use a read-only model from a database that you cannot write to it.
Metadata
Release files for django-readonly-model 1.2
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 | Actions |
|---|---|---|---|---|
| django-readonly-model-1.2.tar.gz | 3.3 kB | Without provenance | Details for django-readonly-model-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_readonly_model-1.2-py3-none-any.whl | Python 3 | none | any | Details for django_readonly_model-1.2-py3-none-any.whl |
Total release size: 8.4 kB
Release files / django-readonly-model-1.2.tar.gz
| Download URL | django-readonly-model-1.2.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea99ff693c8b757371ff56397fb1d057e1a81f913c30bb46d0b67540f05a8bfc
|
|
BLAKE2b-256 checksum How to use checksums |
b4f3556598f1533b7fdca7f32a7c3d8c2f79d74fd72c3eea630dd2e87ba30855
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Release files / django_readonly_model-1.2-py3-none-any.whl
| Download URL | django_readonly_model-1.2-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd60fe234f530d4bd60a23d801cfd6f4b6e8652f2d38377944fdfb47e7bbfa44
|
|
BLAKE2b-256 checksum How to use checksums |
b0917ad69957916da625bc1dbcd4d0637423cfefbb2eee3c9899be2ba87d8c16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Security for django-readonly-model 1.2
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.