Search code examples
tastypie

TastyPie apply authentication only to PUT/POST


How do apply authentication & authorization to PUT and POST methods in TastyPie? I know we can define authentication and authorization in Meta inner class on the resource but how do i let these two methods ONLY to pass thru authentication and authorization layer. I interested in SessionAuthentication and DjangoAuthrization btw.


Solution

  • You can create class based on DjangoAuthrization (add it to Meta then) and override two functions:

    def read_list(self, object_list, bundle):
        return object_list
    
    def read_detail(self, object_list, bundle):     
        return True