开发者

Tastypie difference between list_allowed_methods and detail_allowed_methods

everyone! I need to develop an API for a site written in django, but when I read the tastypie documentation, I got really confused. The documentation is as follows:

allowed_methods

Controls what list & detail REST methods the Resource should respond to. Default is None, which means delegate to the more specific list_allowed_methods & detail_allowed_methods options. You may specify a list like ['get', 'post', 'put', 'delete'] as a shortcut to prevent having to specify the other options.

list_allowed_methods

Controls what list REST methods the Resource should respond to. Default is ['get', 'post', 'put', 'delete'].

detail_allowed_methods

Controls what list REST methods the Resource should respond to. Default is ['get', 'post', 'put', 'delete'].

According to this docs, the list_allowed_methods and detail_allowed_开发者_高级运维methods are exactly the same thing... Is there someone who can tell the difference between them? And what exactly each of them is used for?

Thanks in advance!


OK. I have found the answer and I will just post it here in case this can help somebody out.

The methods start with "list" are responsible for the manipulations on the set returned by tastypie, for example, all the entries of your blog.

While the methods start with "detail" are responsible for the manipulations on an item. For example, one specific entry of your blog.

Wish this could help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜