我正在使用以下代码登录,但后来当我导航index.html
并尝试访问它时,get_profile()
它说 id 未关联。但是当我打印以下变量时,两者都是错误的。我在这里做错了什么?
EDIT
def someotherview(request):
logging.debug(request.user.is_authenticated()) #prints false
logging.debug(request.user.is_active) #prints false
登录方式是这样的
def logon(request):
qd = get_request_type(request)
try:
uname = qd.__getitem__('username')
pwd = qd.__getitem__('password')
user = authenticate(username = uname, password = pwd)
if user is not None:
response_dict.update({'yes':1})
logging.debug("labs_home1 ==================")
return render_to_response('home/index.html', context_instance=RequestContext(request, {'response_dict':response_dict,'a':1}))
else:
response_dict.update({'yes':0})
logging.debug("labs_home2 ==================")
return render_to_response('registration/login.html', context_instance=RequestContext(request, {'response_dict':response_dict,'a':1})
也看看我的问题django get_profile error