drf-extensions icon indicating copy to clipboard operation
drf-extensions copied to clipboard

_is_request_to_detail_endpoint

Open cancan101 opened this issue 9 years ago • 5 comments

Why is _is_request_to_detail_endpoint written like this:

        if hasattr(self, 'lookup_url_kwarg'):
            lookup = self.lookup_url_kwarg or self.lookup_field
...
        return lookup and lookup in self.kwargs

rather than:

return self.action in ['retrieve']:

cancan101 avatar May 12 '15 04:05 cancan101

I don't remember why, but you can change implementation and watch if there are any failing tests. And why don't you like it?

chibisov avatar May 12 '15 08:05 chibisov

It's written like that because it's checking explicitly to see if it's a detail endpoint, so a request that is affecting a specific object (as defined by the lookup). This is slightly different than "a request that is retrieving an object", and can apply to updating and retrieving, as well as custom view methods.

kevin-brown avatar May 12 '15 13:05 kevin-brown

Thank you @kevin-brown.

chibisov avatar May 12 '15 13:05 chibisov

Given what that method is used for internally, do you want the set of requests that it applies to to be as broad as @kevin-brown lists?

cancan101 avatar May 12 '15 14:05 cancan101

@kevin-brown @cancan101 ping about the issue

auvipy avatar Mar 31 '16 08:03 auvipy