quick start:

配置环境(pip install):

1、建立model

2、应用中新建api.py

内容:

from tastypie.resources import ModelResource
from my_app.models import MyModel class MyModelResource(ModelResource):
class Meta:
queryset = MyModel.objects.all()
allowed_methods = ['get']
     resource_name='mymodel' #若没有自动生成类名小写

3、主url配置:

# urls.py
from django.conf.urls import url, include
from myapp.api import EntryResource entry_resource = EntryResource() urlpatterns = [
# The normal jazz here...
url(r'^blog/', include('myapp.urls')),
url(r'^api/', include(entry_resource.urls)),#EntryResource().urls
]

4、runserver localhost:8000

浏览器输入http://localhost:8000/api/mymodel/?format=json 输出有model对象

5、尝试更多地址访问(未添加授权,不支持PUT/DELET/POST操作):

最新文章

  1. ubuntu14.04 安装系统
  2. 将CSDN和WordPress上的旧文章迁移过来
  3. CWebBrowser2获取html的内容
  4. usb驱动开发3之先看core
  5. 通过宏定义判断是否引入的是framework,反之则使用双引号,实用!
  6. sql server2014各版本对比(连接)
  7. CC2530之Flash映射
  8. PHP代码分离
  9. Content-Type实体首部字段
  10. mvc of js
  11. 教你使用python获得字符串的md5值
  12. ASP.NET Core Logging in Elasticsearch with Kibana
  13. 前端小白第一次使用redux存取数据练习
  14. Devexpress Winform MVVM
  15. 如何解决gerrit代码冲突
  16. 图像像素转换 8-bit 16-bit 32-bit游戏效果
  17. Python 自学基础(四)——time模块,random模块,sys模块,os模块,loggin模块,json模块,hashlib模块,configparser模块,pickle模块,正则
  18. js实现静态页面跳转传参
  19. 【网络】<网络是怎样连接的>笔记
  20. asp.net 文件上传

热门文章

  1. 微信小程序内嵌网页 网站生成小程序
  2. 描述进程的PCB
  3. Python自动化--语言基础2--运算符、格式化输出、条件语句、循环语句、列表、元组
  4. 【学习笔记】Spring中的BeanFactory和ApplicationContext 以及 Bean的生命周期(Y2-3-2)
  5. IM开发基础知识补课:正确理解前置HTTP SSO单点登陆接口的原理
  6. spark RDD,DataFrame,DataSet 介绍
  7. 使用Git的hook实现代码的自动部署
  8. 了解一下Http常见状态码、Http协议的工作特点和原理、Http请求Post与Get的区别
  9. 《android开发艺术探索》读书笔记(五)--RemoteViews
  10. nyoj 1129 Salvation 模拟