使用tastype的rest实现。
thinrest的Python项目详细描述
#thin rest
非常薄的一层在django之上,使用[tastype库](https://github.com/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie)来实现restarestaapi的rest-rest-api(使用[tastypie>构建一个简单的接口,可以为两种类型的crud操作提供数据库表:
1。以列为基础,例如雇员(姓名、姓氏、地址、城市、州、邮编)
2。键值对,例如系统设置(设置名称、设置值)
``` pip安装thinrest``
2。将“thinrest”添加到“已安装的应用程序”设置中:
`` python
已安装的应用程序=(
…
“thinrest”,
)
````
3。包括thinrest url
``python
patterns=('',
…
url(r'^thinrest/',include('thinrest.url'),
…
``` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `{
“名字”:“anurag”,
“姓氏”:“agarwal”,
“address”:“wakad”、
“city”:“pune”、
“state”:“maharashtra”、
“邮政编码”:“411057”
}、
“model”:“thinrest.employee”、
“pk”:1
“`````
“employee list:get http://www.example.com/thinrest/api/v1/employee?format=json
员工详细信息:获取http://www.example.com/thinrest/api/v1/employee/1?format=json
employee create/update:post http://www.example.com/thinrest/api/v1/employee/
employee detele:delete http://www.example.com/thinrest/api/v1/employee/1/
对于此类表,将“id”传递给rest将不起作用。因此,在该表的api中很少做一些调整,将列“name”作为输入参数处理。
示例数据:
```{
“fields”:{
“name”:“email”,
“value”:1
},
“model”:“thinrest.systemsetting”,
“pk”:1
`````
设置列表:获取http://www.example.com/thinrest/api/v1/setting?format=json
设置详细信息:获取http://www.example.com/thinrest/api/v1/setting/email?format=json
设置创建/更新:发布http://www.example.com/thinrest/api/v1/setting/
设置详细信息:删除http://www.example.com/thinrest/api/v1/employee/setting/email/
非常薄的一层在django之上,使用[tastype库](https://github.com/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie)来实现restarestaapi的rest-rest-api(使用[tastypie>构建一个简单的接口,可以为两种类型的crud操作提供数据库表:
1。以列为基础,例如雇员(姓名、姓氏、地址、城市、州、邮编)
2。键值对,例如系统设置(设置名称、设置值)
``` pip安装thinrest``
2。将“thinrest”添加到“已安装的应用程序”设置中:
`` python
已安装的应用程序=(
…
“thinrest”,
)
````
3。包括thinrest url
``python
patterns=('',
…
url(r'^thinrest/',include('thinrest.url'),
…
``` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `{
“名字”:“anurag”,
“姓氏”:“agarwal”,
“address”:“wakad”、
“city”:“pune”、
“state”:“maharashtra”、
“邮政编码”:“411057”
}、
“model”:“thinrest.employee”、
“pk”:1
“`````
“employee list:get http://www.example.com/thinrest/api/v1/employee?format=json
员工详细信息:获取http://www.example.com/thinrest/api/v1/employee/1?format=json
employee create/update:post http://www.example.com/thinrest/api/v1/employee/
employee detele:delete http://www.example.com/thinrest/api/v1/employee/1/
对于此类表,将“id”传递给rest将不起作用。因此,在该表的api中很少做一些调整,将列“name”作为输入参数处理。
示例数据:
```{
“fields”:{
“name”:“email”,
“value”:1
},
“model”:“thinrest.systemsetting”,
“pk”:1
`````
设置列表:获取http://www.example.com/thinrest/api/v1/setting?format=json
设置详细信息:获取http://www.example.com/thinrest/api/v1/setting/email?format=json
设置创建/更新:发布http://www.example.com/thinrest/api/v1/setting/
设置详细信息:删除http://www.example.com/thinrest/api/v1/employee/setting/email/