mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-23 23:13:17 +03:00
This commit is contained in:
parent
6b08e97b6a
commit
a9f1d99cb5
|
@ -83,12 +83,6 @@ 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)
|
||||||
|
|
||||||
|
@ -112,7 +106,14 @@ class ViewSetMixin(object):
|
||||||
depending on the request method.
|
depending on the request method.
|
||||||
"""
|
"""
|
||||||
request = super(ViewSetMixin, self).initialize_request(request, *args, **kwargs)
|
request = super(ViewSetMixin, self).initialize_request(request, *args, **kwargs)
|
||||||
self.action = self.action_map.get(request.method.lower())
|
method = request.method.lower()
|
||||||
|
if method == 'options':
|
||||||
|
# This is a special case as we always provide handling for the
|
||||||
|
# options method in the base `View` class.
|
||||||
|
# Unlike the other explicitly defined actions, 'metadata' is implict.
|
||||||
|
self.action = 'metadata'
|
||||||
|
else:
|
||||||
|
self.action = self.action_map.get(method)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user