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:
if number and re.search('[\d\(\)\- \+]+$', number):
r.number(number)
else:
r.client('test')
return str(resp)
Run Code Online (Sandbox Code Playgroud)
url.py
url(r'^voice/(?P<number>\w+)$', 'django_calling.views.generate_xml', name='generating TwiML'),
Run Code Online (Sandbox Code Playgroud)
每当我请求http://127.0.0.1:8000/voice/number?id=98获得以下错误时:
Request Method: GET
Request URL: http://127.0.0.1:8000/voice/number?id=90
Django Version: 1.6.2
Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'get'
Exception Location: /usr/local/lib/python2.7/dist-
Run Code Online (Sandbox Code Playgroud)
完全追溯:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/voice/number?id=90
Django Version: 1.6.2
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_calling',
'django_twilio', …Run Code Online (Sandbox Code Playgroud)