Getting 'str' object has no attribute 'get' in Django

前端 未结 2 1494
春和景丽
春和景丽 2020-12-15 16:00

views.py

def generate_xml(request, number):
    caller_id = \'x-x-x-x\'
    resp = twilio.twiml.Response()

    with resp.dial(callerId=caller_id) as r:
             


        
2条回答
  •  佛祖请我去吃肉
    2020-12-15 16:18

    Django views must always return an HttpResponse object, so try wrapping that string in an HttpResponse:

    from django.http import HttpResponse
    return HttpResponse(str(resp))
    

    Additionally, the number variable in generate_xml will contain only the string 'number', not the GET parameter. To get that, you might use:

    request.GET.get('id')
    

提交回复
热议问题