def post(self, request): username = request.POST.get('username', '') password = request.POST.get('password', '') if not all([username, password]): error = '缺少必要字段' return JsonResponse({'code': -1, 'msg': error}) exists = ClientUser.objects.filter(username=username).exists() if exists: error = '该用户名已存在!' return JsonResponse({'code': -1, 'msg': error}) ClientUser.add(username=username, password=password) return JsonResponse({'code': 0, 'msg': '注册成功,请您登录'})
def post(self, request): username = request.POST.get('username', '') password = request.POST.get('password', '') if not all([username, password]): error = 'Missing Required Information!' return JsonResponse({'code': -1, 'msg': error}) exists = ClientUser.objects.filter(username=username).exists() if exists: error = 'Username already exist!' return JsonResponse({'code': -1, 'msg': error}) ClientUser.add(username=username, password=password) return JsonResponse({ 'code': 0, 'msg': 'Register Success! Please login' })
def post(self, request): username = request.POST.get('username', '') password = request.POST.get('password', '') if not all([username, password]): error = 'missing field' return JsonResponse({'code': -1, 'msg': error}) exists = ClientUser.objects.filter(username=username).exists() if exists: error = 'the user name already exists' return JsonResponse({'code': -1, 'msg': error}) ClientUser.add(username=username, password=password) return JsonResponse({ 'code': 0, 'msg': 'registration successful, please log in' })