Django Tastypie resources.py属性错误。request.method.lower()

Django Tastypie resources.py属性错误。request.method.lower(),django,python-2.7,tastypie,Django,Python 2.7,Tastypie,当我尝试对资源URL(127.0.0.1:8000/api/v1/user/login/)使用POST或GET方法时,我得到了以下错误 回溯(最近一次呼叫最后一次): 文件“/home/mithu/pipliko/pipliko/load_projects/api.py”,第55行,登录 self.method_check(self,allowed=['post','get'])) 文件“/home/mithu/pipliko/local/lib/python2.7/site packages/

当我尝试对资源URL(127.0.0.1:8000/api/v1/user/login/)使用POST或GET方法时,我得到了以下错误

回溯(最近一次呼叫最后一次): 文件“/home/mithu/pipliko/pipliko/load_projects/api.py”,第55行,登录 self.method_check(self,allowed=['post','get'])) 文件“/home/mithu/pipliko/local/lib/python2.7/site packages/tastype/resources.py”,第519行,在方法检查中 request\u method=request.method.lower() 文件“/home/mithu/pipliko/local/lib/python2.7/site packages/tastype/resources.py”,第186行,位于getattr 提升属性错误(名称) AttributeError:方法

我的api.py

def prepend_URL(自身):


您使用的检查方法不正确。尝试使用请求而不是自我:

self.method\u检查(请求,['post','get'])

文件:

    return [
        url(r"^(?P<users>%s)/login%s$" %
            (self._meta.resource_name, trailing_slash()),
            self.wrap_view('login'), name="api_login"),
        url(r'^(?P<users>%s)/logout%s$' %
            (self._meta.resource_name, trailing_slash()),
            self.wrap_view('logout'), name='api_logout'),
    ]           
try:
    print request.method
    self.method_check(self,allowed=['post','get'])
except Exception,e:
    print traceback.format_exc()
    #or
    print sys.exc_info()[0]
data = self.deserialize(request,request.raw_post_data,format = request.META.get('CONTENT_TYPE', 'application/json'))
username = data.get('username','')
password = data.get('password','')
authenticKey = authenticate(username = username,password = password)
if authenticKey:
    if authenticKey.is_active:
        login(request,authenticKey)
        return self.create_response(request,{'success':False, 'user':{'id':user.id}})
    else:
        return self.create_response(request,{'success':False,'reason':'Account disabled'},HttpForbidden);
else:
    return self.create_response(request,{'success':False,'reason':'Wrong credentials'},HttpUnauthorized);