Skip to content

Instantly share code, notes, and snippets.

@akshar-raaj
Created July 8, 2019 07:29
Show Gist options
  • Select an option

  • Save akshar-raaj/812c757d83aab0c0081913c3f6196b43 to your computer and use it in GitHub Desktop.

Select an option

Save akshar-raaj/812c757d83aab0c0081913c3f6196b43 to your computer and use it in GitHub Desktop.
View
class QuestionsView(APIView):
def post(self, request, *args, **kwargs):
serializer = QuestionSerializer(data=request.data)
if serializer.is_valid():
question = serializer.save()
serializer = QuestionSerializer(question)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment