chibisov / drf-extensions

DRF-extensions is a collection of custom extensions for Django REST Framework
http://chibisov.github.io/drf-extensions/docs
MIT License
1.47k stars 208 forks source link

_is_request_to_detail_endpoint #85

Open cancan101 opened 9 years ago

cancan101 commented 9 years ago

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']:
chibisov commented 9 years ago

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?

kevin-brown commented 9 years ago

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.

chibisov commented 9 years ago

Thank you @kevin-brown.

cancan101 commented 9 years ago

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?

auvipy commented 8 years ago

@kevin-brown @cancan101 ping about the issue