user.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:django-open-volunteering-platform 作者: OpenVolunteeringPlatform 项目源码 文件源码
def validate(self, data):
    errors = dict()

    if data.get('password'):
      password = data.get('password', '')
      try:
        validate_password(password=password)
      except ValidationError as e:
        errors['password'] = list(e.messages)

    if data.get('email'):
      email = data.get('email', '')
      users = models.User.objects.filter(email=email, channel__slug=self.context["request"].channel)
      if users.count():
        errors['email'] = "An user with this email is already registered."

    if errors:
      raise serializers.ValidationError(errors)

    return super(UserCreateSerializer, self).validate(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号