def post(self, request, format=json): print '----------------------------------------' data=JSONParser.parse(request) serializer=QuestionSerializer(data=data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=200)
def post(self, request, format=json): print '----------------------------------------' data = JSONParser.parse(request) serializer = QuestionSerializer(data=data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=200)
def post_question(request): if request.method == 'POST': print("data", request.data) serializer = QuestionSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def post(self, request): data = request.data serializer = QuestionSerializer(data=data) if serializer.is_valid(): serializer.save() response = generateresponse('Success', 'question', serializer.data) return Response(response) else: raise InvalidInformation(serializer.errors)
def addQuestion(request, format=json): #Post an order if request.method=='POST': data = JSONParser().parse(request) serializer = QuestionSerializer(data=data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=200) else: return JSONRenderer().render(serializer.errors)
def addQuestion(request, format=json): #Post an order if request.method == 'POST': data = JSONParser().parse(request) serializer = QuestionSerializer(data=data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=200) else: return JSONRenderer().render(serializer.errors)
def create_question(request, format=None): resp_dict = dict(message='', error=0, result='') if request.method == 'POST': serializer = QuestionSerializer(data=request.data) if serializer.is_valid(): if not request.user.is_anonymous: serializer.save(asked_by=request.user) serializer.save() resp_dict.update(result=serializer.data, message='Success') return Response(resp_dict, status=status.HTTP_201_CREATED) else: resp_dict.update(message='Not a valid user', error=1) return Response(resp_dict, status=status.HTTP_403_FORBIDDEN) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)