def restore_object(self, validated_data, instance=None): """ Create or update a new snippet instance, given a dictionary of deserialized field values. Note that if we don't define this method, then deserializing data will simply return a dictionary of items. """ if instance: return instance validated_data['created_at']=datetime.now() return e2eFeedback(**validated_data)
def feedbackSys(request): if request.method == 'GET': data=dict(request.GET) json_data=json.dumps(data) data=yaml.safe_load(json_data) for key,val in data.iteritems(): data[key]=val[0] serializer = FeedBackSerializer(data=data) if serializer.is_valid(): feedback=e2eFeedback() objList=feedback.__class__.objects.all().filter(feedId=data['feedId']) print objList if (len(objList)>0): pass else: serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)