JSON Convertible Model
JSON Convertible Model is a Django app to replace models.Model and make it possible that models will be able to return JSON-Objects directly without creating an new serializer class object. It will not replace the awesome Django-Restframework package but sometimes it is to much afford for me. Detailed documentation is in the “docs” directory.
Quick start
Add “convertable_model” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'convertable_model', ]Create your own models and choose “JSONConvertibleModel” as class to inherit from:
class FooModel(JSONConvertibleModel): ...
2.1. Define which fields you want to use:
class FooModel(JSONConvertibleModel):
...
json_fields = '__all__'
or
class FooModel(JSONConvertibleModel):
...
json_fields = ('field1', 'field2', )
2.2. Define the JSON-Key’s if you want to give them a different name:
class FooModel(JSONConvertibleModel):
...
@jsonify_me
def json_aliases(self):
return {
'foo1': 'IntegerField',
'foo2': 'My_name'
}
2.3 If you want to change the return value of the field:
class FooModel(JSONConvertibleModel):
...
@jsonify_me
def prefix_foobar2(self):
# import is the decorator and that the field name is written in "{foo}_{attribute}"
return self.foobar2.upper()
Metadata
Release files for django-json-convertible-models 0.1.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 | Actions |
|---|---|---|---|---|
| django-json-convertible-models-0.1.1.tar.gz | 7.2 kB | Without provenance | Details for django-json-convertible-models-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_json_convertible_models-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for django_json_convertible_models-0.1.1-py3-none-any.whl |
Total release size: 15.6 kB
Release files / django-json-convertible-models-0.1.1.tar.gz
| Download URL | django-json-convertible-models-0.1.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89faa65d07b2d68f4236485e7a37a039b8f1029a74943cc67b2609afd4a874ac
|
|
BLAKE2b-256 checksum How to use checksums |
309b89509f214a7f8e27bf92b6c9d4dcb562d21925573178ccb3ddf4c5a6aadb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7
|
Release files / django_json_convertible_models-0.1.1-py3-none-any.whl
| Download URL | django_json_convertible_models-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebbcb6ca9f7a934418ec52e4165163f0c22ad1a1a40ec834a0acd46266aa8893
|
|
BLAKE2b-256 checksum How to use checksums |
4ec0ec3bc7e3b6c126d621a16ebc46ac085bc292beef931accfe173b9d6c32b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7
|
Security for django-json-convertible-models 0.1.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.