[Answered ]-What does create_list refer to in Tastypie's custom authorisation?

2πŸ‘

βœ…

The question is about philosophy and concepts, and there are actually 3 questions, but let me try to answer you question briefly.


*_list vs *_detail:

*_list methods are filters of objects user has an access to.

*_detail methods are booleans that tell us, whether we can have an access to the exact object.

Example:

read_list – filters objects, that user will see on site.com/api/v1/cool_object/

read_detail – tells us whether user is allowed to view site.com/api/v1/cool_object/2


Mapping CRUD to HTTP (Tastypie):

CREATE – POST

READ – GET

UPDATE – PUT (to upload new entity) / PATCH (to send changed fields only)

DELETE – DELETE


Why create_list:

The method was added just for the sake of uniformity and consistency. So you were right to see no practical sense in it.

We can even check it in the tastypie/authorization.py:

def create_list(self, object_list, bundle):
    """
    Unimplemented, as Tastypie never creates entire new lists, but
    present for consistency & possible extension.
    """

Leave a comment