【发布时间】:2014-04-27 06:16:20
【问题描述】:
当我使用 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'),
)
【问题讨论】:
-
您应该使用像 pdb 这样的调试器来单步调试您的代码,观察控制流并查看视图返回的内容。
标签: python django-rest-framework