fix: 修复获取 Metadata 时,获取的总是 action 为 metadata

pull/6216/head
xinwen 2021-06-02 17:36:47 +08:00 committed by 老广
parent 4ef3b2630a
commit a809eac2b8
1 changed files with 2 additions and 1 deletions

View File

@ -18,7 +18,7 @@ from rest_framework.request import clone_request
class SimpleMetadataWithFilters(SimpleMetadata):
"""Override SimpleMetadata, adding info about filters"""
methods = {"PUT", "POST", "GET"}
methods = {"PUT", "POST", "GET", "PATCH"}
attrs = [
'read_only', 'label', 'help_text',
'min_length', 'max_length',
@ -32,6 +32,7 @@ class SimpleMetadataWithFilters(SimpleMetadata):
"""
actions = {}
for method in self.methods & set(view.allowed_methods):
view.action = view.action_map.get(method.lower(), view.action)
view.request = clone_request(request, method)
try:
# Test global permissions