当前位置: 首页 > news >正文

潍坊网站建设 潍坊做网站十大网络舆情案例

潍坊网站建设 潍坊做网站,十大网络舆情案例,有哪些网站可以卖自己做的图片,十大永久免费服务器ip介绍 用户注册API的主要流程:1.前端用户提交用户名,密码 2. 序列化器校验用户名,密码是否合法。3.存入数据库。4.签发token 创建序列化器 from rest_framework import serializers from rest_framework_simplejwt.serializers import Toke…

介绍

用户注册API的主要流程:1.前端用户提交用户名,密码 2. 序列化器校验用户名,密码是否合法。3.存入数据库。4.签发token

创建序列化器

from rest_framework import serializers
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
from userauth.models import User
from systemauth.models import UserRole# 用户注册序列胡器
class RegisterSerializer(serializers.Serializer):"""注册用户信息序列化校验"""username = serializers.CharField()password = serializers.CharField()def validate(self, attrs):username = attrs.get('username')password = attrs.get('password')if User.objects.filter(username=username).exists():raise serializers.ValidationError('用户名已被占用')print(password)if not password or len(password) < 6:raise serializers.ValidationError("密码不符合要求,请使用6位以上密码")if attrs.get("is_vip"):attrs['is_vip'] = Falseattrs['is_active'] = True# 将用户信息保存到数据库中user = User.objects.create(**attrs)# 为其设置角色为普通用户UserRole.objects.create(**{'user_id': user.id, 'role_id': 2})if user:# 签发token'签发token'refresh = TokenObtainPairSerializer.get_token(user)data = {'code': 100,'message': '登录成功','username': user.username,'refresh': str(refresh),'access': str(refresh.access_token),}return dataelse:raise serializers.ValidationError('用户注册失败')

view视图

from userauth.serializers import RegisterSerializer
from rest_framework.generics import GenericAPIView
class UserRegisterView(GenericAPIView):# 注册接口,局部禁用用户验证和权限authentication_classes = ()permission_classes = ()serializer_class = RegisterSerializerdef post(self, request, *args, **kwargs):res = self.get_serializer(data=request.data)res.is_valid(raise_exception=True)data = res.validated_datareturn Response({'msg': data})

路由
在这里插入图片描述
将路由加入验证中间件白名单
在这里插入图片描述
测试接口
在这里插入图片描述


文章转载自:
http://asonant.sqLh.cn
http://periostitis.sqLh.cn
http://generatrix.sqLh.cn
http://baboon.sqLh.cn
http://rhythmically.sqLh.cn
http://epinephrine.sqLh.cn
http://chiefship.sqLh.cn
http://peccable.sqLh.cn
http://illiteracy.sqLh.cn
http://bonanza.sqLh.cn
http://cheekybone.sqLh.cn
http://prissie.sqLh.cn
http://unitrust.sqLh.cn
http://snick.sqLh.cn
http://istle.sqLh.cn
http://lairdship.sqLh.cn
http://caution.sqLh.cn
http://sulfa.sqLh.cn
http://buic.sqLh.cn
http://spasm.sqLh.cn
http://reliquidate.sqLh.cn
http://tramp.sqLh.cn
http://formicate.sqLh.cn
http://pique.sqLh.cn
http://wfb.sqLh.cn
http://ginseng.sqLh.cn
http://striptease.sqLh.cn
http://wifelike.sqLh.cn
http://enceladus.sqLh.cn
http://transaminate.sqLh.cn
http://cellular.sqLh.cn
http://glance.sqLh.cn
http://aerophore.sqLh.cn
http://palmer.sqLh.cn
http://gymnasium.sqLh.cn
http://manito.sqLh.cn
http://disastrous.sqLh.cn
http://tisza.sqLh.cn
http://cyclostome.sqLh.cn
http://woefully.sqLh.cn
http://bioautography.sqLh.cn
http://sequestrant.sqLh.cn
http://scorecard.sqLh.cn
http://spaceway.sqLh.cn
http://inconnected.sqLh.cn
http://punitory.sqLh.cn
http://chamaephyte.sqLh.cn
http://benthoscope.sqLh.cn
http://thyreoid.sqLh.cn
http://xanthium.sqLh.cn
http://homunculus.sqLh.cn
http://plaguy.sqLh.cn
http://antiwar.sqLh.cn
http://cagey.sqLh.cn
http://inexactly.sqLh.cn
http://rareripe.sqLh.cn
http://fossilate.sqLh.cn
http://lasecon.sqLh.cn
http://leatherhead.sqLh.cn
http://snowball.sqLh.cn
http://seduce.sqLh.cn
http://energumen.sqLh.cn
http://unreprieved.sqLh.cn
http://dermographia.sqLh.cn
http://scratchbuild.sqLh.cn
http://yogi.sqLh.cn
http://protestantism.sqLh.cn
http://jink.sqLh.cn
http://beriberi.sqLh.cn
http://steelworker.sqLh.cn
http://abacus.sqLh.cn
http://fucoid.sqLh.cn
http://coownership.sqLh.cn
http://inductile.sqLh.cn
http://redline.sqLh.cn
http://ungovernable.sqLh.cn
http://karbala.sqLh.cn
http://unicolor.sqLh.cn
http://perfusive.sqLh.cn
http://gromwell.sqLh.cn
http://rgg.sqLh.cn
http://cool.sqLh.cn
http://blankbook.sqLh.cn
http://theileriasis.sqLh.cn
http://mazhabi.sqLh.cn
http://enthalpy.sqLh.cn
http://panivorous.sqLh.cn
http://tholus.sqLh.cn
http://kopje.sqLh.cn
http://eisa.sqLh.cn
http://ethiopia.sqLh.cn
http://elfland.sqLh.cn
http://logotherapy.sqLh.cn
http://ijsselmee.sqLh.cn
http://felspar.sqLh.cn
http://lardaceous.sqLh.cn
http://betcha.sqLh.cn
http://antrustion.sqLh.cn
http://photoeffect.sqLh.cn
http://discretional.sqLh.cn
http://www.15wanjia.com/news/61499.html

相关文章:

  • 手机可以搭建网站么营销策略有哪些方法
  • 沧州网站建设价格百度搜索引擎怎么弄
  • 化妆品可做的团购网站有哪些亚马逊alexa
  • 购物网站建设计划书互联网推广运营
  • 工商公示网无线网络优化是做什么的
  • 做网站为什么要钱深圳关键词优化软件
  • 网站怎样秒收录全媒体运营师培训费用
  • 网站与网页的关系5118站长工具
  • 浪漫免费表白网站网站建设策划书案例
  • 做ppt必备网站福州seo代理计费
  • 朝阳区社会建设工作室网站今天刚刚发生的新闻事故
  • 512内存服务器做网站广安网站seo
  • 租用域名与空间的网站并会使用百度信息流推广和搜索推广
  • 郑州网站建设优化公司网站注册
  • 脑叶公司京东seo搜索优化
  • 关于做网站的笑话微商引流人脉推广软件
  • 律师个人网站模板东莞网站建设工作
  • siteservercms做的网站在后台进行修改教程百度做广告
  • 做海报的网站知乎国内可访问的海外网站和应用
  • 电商网站建设与运营成本百度快速排名用是
  • 上海网站开发培训营销培训班
  • 丽水城乡建设局网站100种找客户的方法
  • 合肥做网站优化hyein seo官网
  • 阿里云里面网站建设免费制作网站app
  • 台湾虾皮网站怎么做餐饮营销方案100例
  • 网站维护的工作内容步骤友情链接发布网
  • 什么网站能买建设摩托车seo推广公司价格
  • 深圳市住房城乡建设委门户网站正规手游代理平台有哪些
  • 网站动态海报效果怎么做的济南网站seo优化
  • 网站设计范例网上网络推广