Django JSon Schema Field
django-jsonb-schema的Python项目详细描述
#django json模式
[![构建状态](https://travis-ci.org/m19t12/django-json-schema.svg?branch=master)(https://travis ci.org/m19t12/django json模式)
[![覆盖状态](https://coveralls.io/repos/github/m19t12/django-json-schema/badge.svg?branch=master)(https://coveralls.io/github/m19t12/django-json-schema?branch=master)
>django-json模式域。
b数据。
首先创建一个schema类,然后安装django-jsonb-schema
``
\usage
schema类是django抽象模型类(abstract=true)。
验证此dict数据的示例。
`` python
{
‘name':'parent',
‘age':50,
‘son':{
‘name':'son',
‘age':'15',
‘school':{
‘name':'school,
“address”:“school address”
}
}
}
````
我们创建这三个架构类。
我们可以使用任何django模型或第三方字段。
``python
schemas.py
从json架构导入schemaforeverkey,schemaMeta
类学校架构(models.model):
名称=models.charfield(最大长度=128)
地址=models.charfield(最大长度=128)
元=schemaMeta()
类Sonschema(models.model):
名称=models.charfield(最大长度=128)
年龄=models.integerfield()
学校=schemaforeverkey(schoolschema,on_delete=models.cascade)
meta=schemameta()
class parentschema(models.model):
name=models.charfield(max_length=128,default=“test”)
age=models.integerfield()
son=schemaforeverkey(sonschema,on_delete=models.cascade)
meta=schemameta()
```
创建我们的模型。最大长度=256)
simple_int=models.integerfield(blank=true,null=true)
parent=jsonschemafield(schema=parentschema,blank=true)
`````
todo
支持数组元素。
[![构建状态](https://travis-ci.org/m19t12/django-json-schema.svg?branch=master)(https://travis ci.org/m19t12/django json模式)
[![覆盖状态](https://coveralls.io/repos/github/m19t12/django-json-schema/badge.svg?branch=master)(https://coveralls.io/github/m19t12/django-json-schema?branch=master)
>django-json模式域。
b数据。
首先创建一个schema类,然后安装django-jsonb-schema
``
\usage
schema类是django抽象模型类(abstract=true)。
验证此dict数据的示例。
`` python
{
‘name':'parent',
‘age':50,
‘son':{
‘name':'son',
‘age':'15',
‘school':{
‘name':'school,
“address”:“school address”
}
}
}
````
我们创建这三个架构类。
我们可以使用任何django模型或第三方字段。
``python
schemas.py
从json架构导入schemaforeverkey,schemaMeta
类学校架构(models.model):
名称=models.charfield(最大长度=128)
地址=models.charfield(最大长度=128)
元=schemaMeta()
类Sonschema(models.model):
名称=models.charfield(最大长度=128)
年龄=models.integerfield()
学校=schemaforeverkey(schoolschema,on_delete=models.cascade)
meta=schemameta()
class parentschema(models.model):
name=models.charfield(max_length=128,default=“test”)
age=models.integerfield()
son=schemaforeverkey(sonschema,on_delete=models.cascade)
meta=schemameta()
```
创建我们的模型。最大长度=256)
simple_int=models.integerfield(blank=true,null=true)
parent=jsonschemafield(schema=parentschema,blank=true)
`````
todo
支持数组元素。