本文整理汇总了Python中rest_framework.parsers.MultiPartParser方法的典型用法代码示例。如果您正苦于以下问题:Python parsers.MultiPartParser方法的具体用法?Python parsers.MultiPartParser怎么用?Python parsers.MultiPartParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rest_framework.parsers
的用法示例。
在下文中一共展示了parsers.MultiPartParser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parser_classes
# 需要导入模块: from rest_framework import parsers [as 别名]
# 或者: from rest_framework.parsers import MultiPartParser [as 别名]
def parser_classes(self):
if getattr(self, 'action', None) in ['set_content']:
return [MultiPartParser]
else:
return api_settings.DEFAULT_PARSER_CLASSES
示例2: parser_classes
# 需要导入模块: from rest_framework import parsers [as 别名]
# 或者: from rest_framework.parsers import MultiPartParser [as 别名]
def parser_classes(self):
if getattr(self, 'action', None) in ['resource_file']:
return [MultiPartParser]
else:
return api_settings.DEFAULT_PARSER_CLASSES
示例3: parser_classes
# 需要导入模块: from rest_framework import parsers [as 别名]
# 或者: from rest_framework.parsers import MultiPartParser [as 别名]
def parser_classes(self):
if getattr(self, 'action', None) in ['set_settings_file']:
return [MultiPartParser]
else:
return api_settings.DEFAULT_PARSER_CLASSES
示例4: parser_classes
# 需要导入模块: from rest_framework import parsers [as 别名]
# 或者: from rest_framework.parsers import MultiPartParser [as 别名]
def parser_classes(self):
if getattr(self, 'action', None) in ['set_accounts_file', 'set_location_file', 'set_reinsurance_info_file', 'set_reinsurance_scope_file']:
return [MultiPartParser]
else:
return api_settings.DEFAULT_PARSER_CLASSES
示例5: testupload
# 需要导入模块: from rest_framework import parsers [as 别名]
# 或者: from rest_framework.parsers import MultiPartParser [as 别名]
def testupload(self):
"""
Ensure request.POST returns no content for POST request with file content.
"""
factory = APIRequestFactory()
upload = SimpleUploadedFile("file.txt", b"file_content")
request = Request(factory.post('App/upload', {'upload': upload}))
request.parsers = (FormParser(), MultiPartParser())
assert list(request.POST) == []
assert list(request.FILES) == ['upload']