def upload_image(self, request, pk=None): """ Upload an image to a recipe """ recipe = self.get_object() serializers = self.get_serializer(recipe, data=request.data) if serializers.is_valid(): serializers.save() return Response(serializers.data, status=status.HTTP_200_OK) return Response(serializers.errors, status=status.HTTP_400_BAD_REQUEST)
def perform_create(self, serializers): """ Create a new recipe """ serializers.save(user=self.request.user)
def perform_create(self, serializers): """ create a new tag """ serializers.save(user=self.request.user)