摘要: #测试APIView的request from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status from app.mo 阅读全文
posted @ 2020-09-25 20:06 亦木121 阅读(127) 评论(0) 推荐(0)
摘要: #测试APIView的request from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status from app.mo 阅读全文
posted @ 2020-09-25 16:50 亦木121 阅读(99) 评论(0) 推荐(0)
摘要: GenericAPIView 1、继承自APIView,为列表视图和详情视图添加了常用的行为和属性 1)行为(方法) get_queryset:获取queryset的数据集 get_serializer:获取serializer_class序列化器对象 get_object:根据lookup_fie 阅读全文
posted @ 2020-09-25 10:36 亦木121 阅读(166) 评论(0) 推荐(0)
摘要: 定位的三种方式:标准流、浮动、定位。 1.浮动 1)浮动的特性:a脱标:浮动到指定位置,原来的位置不保留;b一行内显示,元素顶部对齐;c浮动的元素具有行内块的特性 父盒子居中显示 {margin:0 auto;} 阅读全文
posted @ 2020-09-23 16:24 亦木121 阅读(111) 评论(0) 推荐(0)
摘要: urls.py的配置 from django.conf.urls import url,include from django.contrib import admin from app import views from django.urls import path urlpatterns = 阅读全文
posted @ 2020-09-18 16:38 亦木121 阅读(530) 评论(0) 推荐(0)
摘要: APIView实现列表视图 #测试APIView的request from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import stat 阅读全文
posted @ 2020-09-18 15:01 亦木121 阅读(126) 评论(0) 推荐(0)
摘要: 1、继承自view 2、提供了rest_framework自己的request对象,不是django里的HttpRequest对象 3.返回了est_framework自己的response队形,不时django里的HttpResponset对象 4.并且提供了权限、认证、限流等功能 View获取数 阅读全文
posted @ 2020-09-18 09:35 亦木121 阅读(156) 评论(0) 推荐(0)
摘要: 1、工程的创建 1)定位到需要创建工程的文件夹 django-admin startproject xxx 2)settings里配置数据库 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'books 阅读全文
posted @ 2020-09-17 21:58 亦木121 阅读(187) 评论(0) 推荐(0)
摘要: 模型类的定义 from django.db import models # Create your models here. class BookInfo(models.Model): btitle = models.CharField(max_length=20,verbose_name='名称' 阅读全文
posted @ 2020-09-17 20:31 亦木121 阅读(168) 评论(0) 推荐(0)
摘要: 1、Modelserializer会根据模型类自动生成字段 2、还可以手动添加字段 3、提供了反序列化时用的create方法和update方法,不需要再手动在序列化器中创建create方法 from rest_framework import serializers from app.models 阅读全文
posted @ 2020-09-17 20:02 亦木121 阅读(190) 评论(0) 推荐(0)