The company I work for has 2 projects that use django and DRF 3.
ModelViewSet allowed_methods property and are just using whatever DRF figures should be the defaultcreate(), update(), partial_update(), patch(), etc.)However, in one project the allowed_methods property defaults to [u'GET', u'PUT', u'PATCH', u'DELETE', u'HEAD', u'OPTIONS']. For the other allowed_methods defaults to [u'GET', u'POST', u'HEAD', u'OPTIONS']. Consequently, I get a 405 response with
Method "PATCH" not allowed.
when I attempt to send a PATCH request.
What causes project 2 to be more restricted?
DRF only exposes Django's internal _allowed_methods() so we should review the implementation of that method:
def _allowed_methods(self):
return [m.upper() for m in self.http_method_names if hasattr(self, m)]
where self.http_method_names is defined as:
http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']
Is there a difference in what methods these clases define that could explain what you're seeing?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With