【发布时间】:2014-11-07 01:22:51
【问题描述】:
我正在进行服务基本登录,我需要在 Django 视图中使用代码 200 和 JSON 来回答,但我不知道这是否是使用 HttpResponse 库的正确形式?
def Login(email,password):
User=CUser()
if User.is_valid(email,password) :
user=User.find(email)
datos['Id'] = str(user['Id'])
datos['Name'] = user['Name']
datos['LastName'] = user ['LastName']
datos['Email'] = user ['Email']
return HttpResponse(json.dumps(data), content_type = "application/json",status_code = 200)
else:
return HttpResponse( content_type = "application/json",status_code = 400)
我将在 android 登录中使用此响应,为此我需要控制台上的 django 返回之类的状态代码
【问题讨论】:
标签: python json django django-views http-status-codes