Django判断数据库中是否有该记录
引用草原上之狼的回答:
用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")
用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':'手机号可注册'})
Users.objects.get(useraccount=userPhone)
return JsonResponse({'res':0,'msg':'手机号已被注册'})
except:
return JsonResponse({'res':1,'msg':'手机号可注册'})
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询