在视类
在视当中查询上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口要返回的数据,并制定过滤器
然后安装app
使用上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口分页首先安装djangorestframework模块
然后编写api的路由urls
DEFAULT_PAGINATION_CLASSrest_framework自带的分页器PAGE_SIZE单页的数量上面是后端开发要完成的工作前端开发需要基于当前的上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口使用vue-resource进行上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口请求和数据绑定数据绑定首先要解决django和vue的代码冲突问题
上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口的分页配置
最原始的上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口搭建是使用类视搭建上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口,后来发现上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口规范很难约束。就有前辈写了上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口框架,使用框架进行规范的上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口开发。这个叫restful,django拥有restful的插件
djangorestframework
Pip install djangorestframework
Pip install django-filter
Pip install Markdown
按照功能对项目进行划分:创建serializers文件,用来存放上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口的过滤器
使用上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口尽量需要有数据库模型
配置settings
编写对应的过滤器
编写上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口逻辑
from django.contrib import admin
from django.urls import path,include,re_path
from Buyer.views import index
from Store.models import Goods
from Store.models import GoodsType
from rest_framework import routers, serializers, viewsets
# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
'''
声明数据
'''
class Meta: #元类
model = Goods #要进行上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口序列化的模型
fields = ['goods_name', 'goods_price', 'goods_number', 'goods_description'] #序列要返回的字段
# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
queryset = Goods.objects.all() #具体返回的数据
serializer_class = UserSerializer #指定过滤的类
class GoodsTypeSerializer(serializers.HyperlinkedModelSerializer):
'''
声明查询的表和返回的字段
'''
class Meta:
model = GoodsType
fields = ['name','description']
class TypeViewSet(viewsets.ModelViewSet):
'''
返回具体查询的内容
'''
queryset = GoodsType.objects.all()
serializer_class = GoodsTypeSerializer
router = routers.DefaultRouter() #声明一个默认的路由注册器
router.register(r'goods',UserViewSet) #注册写好的上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口视图
router.register(r'goodsType',TypeViewSet) #注册写好的上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口视图
urlpatterns = [
path('admin/', admin.site.urls),
path('Store/', include('Store.urls')),
path('Buyer/', include('Buyer.urls')),
path('ckeditor/',include('ckeditor_uploader.urls')),
re_path('^API', include(router.urls)), #restful 的根路由
re_path('^api-auth',include('rest_framework.urls')) #上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口认真
]
urlpatterns += [
re_path(r'^$',index)
]
在路由当中注册上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口
然后在配置当中添加分页配置
然后编写配置
再编写具体模型的路由Urls
解决绑定的范围问题
在web端使用上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口,通常要用到ajax和vue数据通过上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口返回然后前端使用ajax进行请求,使用vue进行渲染这里我使用的是vueResource大家在使用代码的时候,先导入vue,在导入vueResource的js配置
Vue.use(VueResource);
var vue = new Vue(
{
el: '#goods',
data: {
goods_list: []
},
created:function () {
this.$http.get('/APIgoods/').then(
function (data) {
this.goods_list = data.data;
console.log(data.data)
},
function (error) {
console.log(error)
}
)
},
methods: {
}
}
);
Postman基本使用和上证所程序化交易上证所程序化交易接口,接口,上证所程序化交易接口,接口数据过滤下次再讲
文章为作者独立观点,不代表股票交易接口观点