0
我在django.I很新,我想驗證用戶。但我無法使用身份驗證功能來執行此操作。我在django中查看過身份驗證功能。在那裏它總是顯示TypeError。我在不同的時間使用了unicode和string,但總是顯示TypeError。 請任何幫助,將不勝感激。 我attching我下面的代碼:Django身份驗證錯誤
def loginTest(request):
if request.method == 'POST':
user = authenticate(username=request.POST['username'], password=request.POST['password'])
if user is not None:
login(request,user)
return HomePage(request)
else:
return HttpResponseRedirect('/login/')
def login(request):
return render_to_response('login.html', {}, context_instance=RequestContext(request))
@login_required(login_url='/login/')
def HomePage(req):
templ = get_template('HomePage.html')
variables = Context({})
output = templ.render(variables)
return HttpResponse(output)