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)
user.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录