Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tastypie difference between list_allowed_methods and detail_allowed_methods

Tags:

django

api

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!

like image 387
Mathieu Avatar asked Jul 19 '11 07:07

Mathieu


1 Answers

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!

like image 109
Mathieu Avatar answered Sep 20 '22 05:09

Mathieu