[](https://travis-ci.org/m19t12/django-json-schema)
[](https://coveralls.io/github/m19t12/django-json-schema?branch=master)
Django JSON Schema Field.
## Table of content
- [Introduction](#introduction)
- [Installing](#installing)
- [Usage](#usage)
- [TODO](#TODO)
## Introduction
Django JSON Schema is a library for displaying and validating
postgresql jsonb data.
## Installing
```
pip install django_jsonb_schema
```
## Usage
First you create a schema class.
Schema class is a django abstract model class (abstract = True).
You can import SchemaMeta class or create an abstract class.
If you want to validate and display nested data you can do this with the SchemaForeignKey.
For example to validating this dict data.
```python
{
'name': 'parent',
'age': 50,
'son': {
'name': 'son',
'age': '15',
'school': {
'name': 'school',
'address': 'school address'
}
}
}
```
We create this three schema classes.
We can use any django model or third party field.
```python
#schemas.py
from json_schema.models import SchemaForeignKey, SchemaMeta
class SchoolSchema(models.Model):
name = models.CharField(max_length=128)
address = models.CharField(max_length=128)
Meta = SchemaMeta()
class SonSchema(models.Model):
name = models.CharField(max_length=128)
age = models.IntegerField()
school = SchemaForeignKey(SchoolSchema, on_delete=models.CASCADE)
Meta = SchemaMeta()
class ParentSchema(models.Model):
name = models.CharField(max_length=128, default="test")
age = models.IntegerField()
son = SchemaForeignKey(SonSchema, on_delete=models.CASCADE)
Meta = SchemaMeta()
```
After we create our model.
```python
#models.py
from django.db import models
from json_schema.fields import JSONSchemaField
from .schemas import ParentSchema
class JSONSchemaModel(models.Model):
simple_text = models.CharField(blank=True, null=True, max_length=256)
simple_int = models.IntegerField(blank=True, null=True)
parent = JSONSchemaField(schema=ParentSchema, blank=True)
```
## TODO
Support array elements.
Metadata
Release files for django-jsonb-schema 0.7.0
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-jsonb-schema-0.7.0.tar.gz | 4.4 kB | Without provenance | Details for django-jsonb-schema-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_jsonb_schema-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for django_jsonb_schema-0.7.0-py3-none-any.whl |
Total release size: 22.3 kB
Release files / django-jsonb-schema-0.7.0.tar.gz
| Download URL | django-jsonb-schema-0.7.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e85f228bf2a75b9bfd5f0104712653730cdbb9af026afc2de93456eb6aefa88f
|
|
BLAKE2b-256 checksum How to use checksums |
b6759832e1f23c77e5eb77e90bccd7c79da8003a0a58c7fa9ddf040239f0a70f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1
|
Release files / django_jsonb_schema-0.7.0-py3-none-any.whl
| Download URL | django_jsonb_schema-0.7.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c8a8775f5f0cba823f574c37a0d12693fa2aa4d76fe449a397243cc29d14bec
|
|
BLAKE2b-256 checksum How to use checksums |
ca1aa9788bc1a6d2dd69f8920c9a1c4f800c8ac2eecf8dac9d6581f999e9a258
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1
|
Security for django-jsonb-schema 0.7.0
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.