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.
有没有在美味派中使用 APIKey 身份验证的示例。提供的示例并未真正详细说明其工作原理。
此外,我正在翻阅食谱,试图找到在帖子上返回自定义消息的钩子。
例如,有人发帖试图创建一个用户,但该用户已经存在。在我的 hydra_user(self, bundle): 我相信我会进行检查,但我将如何返回有用的错误消息?
你可以这样做:
from tastypie.exceptions import ImmediateHttpResponse from tastypie.http import HttpBadRequest if test_fails: raise ImmediateHttpResponse(HttpBadRequest("User already exists"))