JSON Web Token不再维护,故不使用。
官方建议的是使用simpleJWT认证
并且最新版本的Django和DRF如果使用JSON Web Token,项目启动会报错
ImportError: Could not import 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: ca
关于普通序列化器和模型序列化器
1:普通序列化器
众所周知Response不能直接返回orm对象的,所以需要我们进行序列化操作,可以通过手动将其转为字典或JSON,也可以使用DRF所提供的序列化器
####下面的是代码模块
import re
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
# 部门的序列化器
from users.models
nil :作为 List[T]的初始化,表示一个空数组 官方文档解释
null :表示一个空对象,是Null唯一的实例
Null :不用怎么管这个,基本不会用到。
Nothing and Null
Nothing is a subtype of all types, also called the bottom type. There is no value that has type Nothing. A common use is to signal non-termination