当我在终端上使用curl命令执行以下命令时
curl -X POST http://myuser:mypassword@myweb.com:8000/call/make-call/ -d "tutor=1&billed=1"
我遇到了以下错误
在/call/make-call/处出现了AssertionError,预期应该从视图返回一个
Response
、HttpResponse
或HttpStreamingResponse
,但却收到了一个<type 'NoneType'>
我的views.py文件如下
@api_view(['GET', 'POST'])
def startCall(request):
if request.method == 'POST':
serializer = startCallSerializer(data=request.DATA)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
我的serializer.py文件是:
class startCallSerializer(serializers.ModelSerializer):
class Meta:
model = call
fields = ('tutor', 'billed', 'rate', 'opentok_sessionid')
我的 urls.py 文件是
urlpatterns = patterns(
'api.views',
url(r'^call/make-call/$','startCall', name='startCall'),
)