Quando faccio il seguente comando nel corso Terminal utilizzando riccioloDjango-Rest-quadro AssertionError HttpResponse Expected
curl -X POST http://myuser:[email protected]:8000/call/make-call/ -d "tutor=1&billed=1"
ottengo il seguente errore
AssertionError a/call/make-call/aspettavamo un
Response
,HttpResponse
oHttpStreamingResponse
da restituire dalla vista , ma ha ricevuto un<type 'NoneType'>
mio 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)
mia serializer.py è
class startCallSerializer(serializers.ModelSerializer):
class Meta:
model = call
fields = ('tutor', 'billed', 'rate', 'opentok_sessionid')
mia urls.py è
urlpatterns = patterns(
'api.views',
url(r'^call/make-call/$','startCall', name='startCall'),
)
si consiglia di utilizzare un debugger come PPB per passare il codice, guardare il flusso di controllo e vedere ciò che viene restituito dalla vista. – rubayeet