在写一个login页面,用的guest用户,从别处拷贝来了一套代码(这套代码在别处是好使的)。
浏览器的请求数据username "guest" password "123456"发送到了django。django也从数据库根据请求取到了(数据库里只有一个表USER_INFO)
django中有一段request.session的内容,不太熟。感觉是这部分的错,自己感觉是不是得数据库里配置点什么东西,或者啥的。
debug就只报了下面这个错,也没显示报错具体在哪行哪个位置
DatabaseError at /server/authorize/login/
ORA-00942: table or view does not exist
下面是django里/server/authorize/login/相关部分的代码
def auth_login(request):
m = UserInfo.objects.get(username=username)
if m.passwd == request.POST.get('password',''):
request.session['is_login'] = 'True'
uid =m.userid
request.session['member_id'] = uid
s = request.META["REMOTE_ADDR"]
s_data = s.split(".")
if s_data[0] != "22" or (s_data[0] == "22" and (s_data[1] != "126" and s_data[1] != "127")):
request.session.set_expiry(0)
else :
request.session.set_expiry(0)
try:
curuser = User.objects.get(id=uid)
except:
r = {"res":"Django_User Table Can't Query","err_uid":uid}
return HttpResponse(json.dumps(r),content_type="application/json")
group = Group.objects.filter(user=curuser)
g_counts = Group.objects.filter(user=curuser).count()
if g_counts != 0 :
groups = repr(group)
grplist = to_list(groups)
user = UserInfo.objects.get(userid=uid)
request.session['groups'] = grplist
r = {"name":user.name,"username":user.username,"phone":user.phone,"mobile_phone":user.mobile_phone,"email":user.email,"group_id":grplist,"user_id":user.userid}
r1 = {"res":1,"data":r}
return HttpResponse(json.dumps(r1),content_type="application/json")
elif g_counts == 0 :
request.session['groups'] = "null"
user = UserInfo.objects.get(userid=uid)
r = {"name":user.name,"username":user.username,"phone":user.phone,"mobile_phone":user.mobile_phone,"email":user.email,"group_id":"null","user_id":user.userid}
r1 = {"res":1,"data":r}
return HttpResponse(json.dumps(r1),content_type="application/json")
else:
r = {"res":-1}
return HttpResponse(json.dumps(r),content_type="application/json")