# Substituting derivative in equation

There is likely a simple way to solve this, but I cannot seem to find a way. Let say I have two functions, f(x,y) and g(x,y)

var('x,y')

f=function('f',x,y)

g=function('g',x,y)

I want to be able to substitute a value for one of the derivatives. For example, if I have the equation x^2y+f.diff(x,1), I may want to substitute in the function g, so I have x^2y+g. I tried the following

(x^2y+f.diff(x,1)).subs(f.diff(x,1)=g)

And get an error that a keyword can't be an expression. Is there anyway to make this substitution?