Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我看来,我正在使用该资源。每当出现错误时,它们将在 immediatehttpresponse 及其 httpbadrequest 对象中返回。当我执行 r.response 时,我可以看到 xml 格式的内容,但我无法检索状态代码。如何处理错误响应?
except ImmediateHttpResponse, r: print r.response
在 HttpBadRequest 的情况下,状态码始终为 400(第 41 行的 tastypie.http):
class HttpBadRequest(HttpResponse): status_code = 400
还:
r.status_code
应该给你。