当我使用 python manage.py runserver 命令在本地运行我的活塞应用程序但返回时,我的活塞应用程序工作正常但返回
urllib2.HTTPError:HTTP 错误 403:禁止
在阿帕奇下。如何调试 django-piston 应用程序?
当我使用 python manage.py runserver 命令在本地运行我的活塞应用程序但返回时,我的活塞应用程序工作正常但返回
urllib2.HTTPError:HTTP 错误 403:禁止
在阿帕奇下。如何调试 django-piston 应用程序?
我通常通过以下方式调试活塞应用程序:
您可以有条件地更改为 BasicAuthentication ,如下所示:
auth = {'authentication': WhateverYouAreUsingForAuthentication(realm="YourSite")}
if getattr(settings, "API_DEBUG", None):
from piston.authentication import HttpBasicAuthentication
auth = {'authentication': HttpBasicAuthentication(realm="Spling")}
some_handler = Resource(SomeHandler, **auth)
要使用 curl 传递用户名和密码,请使用以下-u
选项:
curl -u username:password http://localhost:8000/api/some/endpoint/
因此,在您的本地设置模块中,API_DEBUG=True
只要您想使用基本身份验证,就可以进行设置。