def dispatch(self, request, *args, **kwargs):
response = super(TwilioResponseMixin, self).dispatch(request, *args, **kwargs)
# handle view returning httpresponse instead of string.
# this will allow more customizability if some functions return
# and others return httpresponse objects.
if isinstance(response, HttpResponse):
if isinstance(response, SimpleTemplateResponse):
response.render()
content = response.content
elif isinstance(response, basestring):
content = response
else:
print type(response)
content = ''
twilio_response = twilio.twiml.Response()
twilio_response.message(msg=content, to=request.session['phone_num'],
sender=PLIVO_NUMBER)
response = HttpResponse(content=str(twilio_response))
return response
评论列表
文章目录