2012-07-30 3 views
0

파이썬 httplib을 사용하여 Django tastypie에 연결하는 REST API를 구현했습니다. 난 상태 코드를 얻으려고 할 때마다 그러나 오류 다음 표시되어HTTPResponse 인스턴스에 'status_code'속성이 없습니다. python/django

AttributeError at /actions/login 
HTTPResponse instance has no attribute 'status_code' 

내 코드가

import hashlib 
import hmac 
from django.shortcuts import render_to_response 
from django.template import RequestContext 

def loginAction(request): 
    username=request.POST['email'] 
    password=request.POST['password'] 
    import httplib, urllib 
    params = urllib.urlencode({'username': username}) 
    #hash username here to authenticate 
    digest=hmac.new("qnscAdgRlkIhAUPY44oiexBKtQbGY0orf7OV1I50", str(request.POST['password']),hashlib.sha1).hexdigest() 
    auth=username+":"+digest 
    headers = {"Content-type": "application/json","Accept": "text/plain","Authorization":auth} 
    conn = httplib.HTTPConnection("localhost",8000) 
    conn.request("POST", "/api/ecp/profile/", params, headers) 
    conn.set_debuglevel(1) 
    response = conn.getresponse() 
    return response 

답변

관련 문제