Python rest_framework.parsers 模块,FormParser() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用rest_framework.parsers.FormParser()

项目:Pyphon    作者:pyphonic    | 项目源码 | 文件源码
def post(self, request, *kwargs):
        parser = FormParser()
        query_dict = parser.parse(request)
        contact = Contact.objects.filter(number=query_dict["From"]).first()
        if not contact:
            contact = Contact(number=query_dict["From"])
            contact.save()
        if contact.number != os.environ["TWILIO_NUMBER"]:
            sender = "them"
        else:
            sender = "you"
        text = Text(sender=sender, contact=contact, body=query_dict["Body"])
        text.save()
        return HttpResponse()
项目:Sentry    作者:NetEaseGame    | 项目源码 | 文件源码
def select_parser(self, request, parsers):
        if request.method == 'POST':
            parsers = [FormParser(), MultiPartParser()]

        return super(ConditionalContentNegotiation, self).select_parser(
            request, parsers
        )