zoukankan      html  css  js  c++  java
  • django-restframework

    django-restframework

    一、安装

    >: pip3 install djangorestframework
    

    二、使用

    • 在settings.py中注册:

      INSTALLED_APPS = [   
          ....
          'api.apps.ApiConfig',
          # drf必须注册
          'rest_framework',
      ]
      

    三、模块

    # drf的封装风格
    from rest_framework.views import APIView  # CBV
    from rest_framework.response import Response # 响应
    from rest_framework.request import Request # 请求
    from rest_framework.filters import SearchFilter # 过滤器
    from rest_framework.pagination import PageNumberPagination # 分页
    from rest_framework.exceptions import APIException # 异常
    from rest_framework.authentication import BaseAuthentication # 验证
    from rest_framework.permissions import IsAuthenticated # 组件
    from rest_framework.throttling import SimpleRateThrottle # 
    from rest_framework.settings import APISettings  # rest_framework配置文件
    from rest_framework import status # 状态码
    
    from django.http.request import QueryDict  # 类型
    
    • 基于CBV完成满足RSSTful规范接口
  • 相关阅读:
    codefoces 1405 D Tree Tag
    洛谷P3413 萌数
    数位DP模板
    leetcode 统计所有可行路径
    Josephus Transform 加速置换
    牛客IOI周赛18-提高组 排列
    Find a way HDU
    Oil Deposits HDU
    Fire! UVA
    Pots POJ
  • 原文地址:https://www.cnblogs.com/randysun/p/12288739.html
Copyright © 2011-2022 走看看