drf-extensions
drf-extensions copied to clipboard
_is_request_to_detail_endpoint
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']:
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?
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.
Thank you @kevin-brown.
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?
@kevin-brown @cancan101 ping about the issue