mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Store self.action='metadata' for OPTIONS requests on viewsets. Closes #3115.
This commit is contained in:
parent
11e3cfbf6e
commit
538ffaf6c7
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user