0
当我在Tastypie中实现自己的obj_create()时,正确的失败方式是什么(因为我知道例如超出了一些配额)?我想有一个标准的例外,但我不知道哪一个。我应该如何向Tastypie表明我无法创建资源?
当我在Tastypie中实现自己的obj_create()时,正确的失败方式是什么(因为我知道例如超出了一些配额)?我想有一个标准的例外,但我不知道哪一个。我应该如何向Tastypie表明我无法创建资源?
通过提高ImmediateHttpResponse
例外,其中一个tastypie.http
HttpResponse
(来自Django)子类。
from tastypie.exceptions import ImmediateHttpResponse
from tastypie.http import HttpSeeOther
...
raise ImmediateHttpResponse(HttpSeeOther())