摘要: Part 1. ViewSet >> 可以自动帮忙把BookList 和 BookDetail 写在一起。 from rest_framework import viewsets # class PublisherList(generics.ListCreateAPIView): # queryse 阅读全文
posted @ 2018-08-21 22:17 小小Guido妹 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1. Models 里再添加一个表, 并有外建关联。 from django.db import models class Publisher(models.Model): name = models.CharField(max_length=32, verbose_name="Publisher 阅读全文
posted @ 2018-08-21 21:48 小小Guido妹 阅读(454) 评论(0) 推荐(0) 编辑
摘要: https://q1mi.github.io/Django-REST-framework-documentation/tutorial/4-authentication-and-permissions_zh/ 1. models.py 表里面加入一列 “operater", 并且重新migrate 阅读全文
posted @ 2018-08-21 21:16 小小Guido妹 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Part 1. API View: from helloworld.models import Publisher from helloworld.serializers import PublisherSerializer from rest_framework.response import R 阅读全文
posted @ 2018-08-21 20:45 小小Guido妹 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Part 1. 请求与响应 在views.py 里面添加新的API from helloworld.models import Publisher from helloworld.serializers import PublisherSerializer from rest_framework.d 阅读全文
posted @ 2018-08-21 20:03 小小Guido妹 阅读(646) 评论(0) 推荐(0) 编辑
摘要: >> 按照官网创建prject + app Part 1. 序列化: (把数据库数据转化成特定格式json, 个人理解) 采用原生的序列化方法: def publisher_list(request): queryset = Publisher.objects.all() data = [] # [ 阅读全文
posted @ 2018-08-21 19:28 小小Guido妹 阅读(134) 评论(0) 推荐(0) 编辑