用if语句判断一下就可以了,比如
查找users表中是否存在email为接收到email的记录
userinfo = Users.objects.get(email = request.POST['email'])if userinfo: print("yes,we have this email")else: print("sorry,email is not register")
try:
Users.objects.get(useraccount=userPhone)
return JsonResponse({'res':0,'msg':'手机号已被注册'})
except:
return JsonResponse({'res':1,'msg':'手机号可注册'})