Store self.action='metadata' for OPTIONS requests on viewsets. Closes #3115.

This commit is contained in:
Tom Christie 2015-07-14 11:13:26 +01:00
parent 11e3cfbf6e
commit 538ffaf6c7

View File

@ -83,6 +83,12 @@ class ViewSetMixin(object):
if hasattr(self, 'get') and not hasattr(self, 'head'): if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get self.head = self.get
# Explicitly map `options` requests to an (implicit) action named
# 'metadata'. This action doesn't actually exist as a named method,
# because, unlike other methods, we always route to it.
if hasattr(self, 'options'):
self.action_map['options'] = 'metadata'
# And continue as usual # And continue as usual
return self.dispatch(request, *args, **kwargs) return self.dispatch(request, *args, **kwargs)