我使用以下代碼登錄,但稍後當我從index.html
導航並嘗試訪問get_profile()
時,它表示該ID未關聯。但是,當我打印下面的變量都是錯誤的。我在這裏做錯了什麼?Django用戶驗證錯誤
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
您的用戶來自哪裏?有登錄表單嗎? uname和pwd來自哪裏? – Jingo 2012-07-17 14:26:00
uname和pwd來源於html模板。並且輸入來自表格 – Rajeev 2012-07-17 14:28:33