def post(self, request, format=None): serializer = GeoLocationSerializer(data=request.data) if request.data['username'] in CreatedBy().values_key( 'username', CreatedBy().all()): if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def delete(self, request, id, format=None): response = CreatedBy().delete(id) if response == 204: return Response(status=status.HTTP_204_NO_CONTENT) return Response(status=status.HTTP_400_BAD_REQUEST)
def put(self, request, id, format=None): createdby = CreatedBy().put(id, request.data) if createdby.status_code == 200: return Response(createdby.json(), status=status.HTTP_200_OK) return Response(status=status.HTTP_400_BAD_REQUEST)
def get_object(self, id): createdby = CreatedBy().get(id) if createdby != 200: raise Http404 return createdby
def post(self, request, format=None): createdby = CreatedBy().create(request.data) if createdby.status_code == 201: return Response(createdby.data, status=status.HTTP_201_CREATED) return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, format=None): print(CreatedBy().values_key('username', CreatedBy().all())) return Response(CreatedBy().all())
def create(self, validated_data): print(validated_data) return CreatedBy().create(validated_data)