'Polynomial division with remainder of ``f`` by ``g``.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x
>>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x))
(Poly(1/2*x + 1, x, domain=\'QQ\'), Poly(5, x, domain=\'QQ\'))
>>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x), auto=False)
(Poly(0, x, domain=\'ZZ\'), Poly(x**2 + 1, x, domain=\'ZZ\'))'

def div(f, g, auto=True):

    (dom, per, F, G) = f._unify(g)
    retract = False
    if (auto and dom.is_Ring and (not dom.is_Field)):
        (F, G) = (F.to_field(), G.to_field())
        retract = True
    if hasattr(f.rep, 'div'):
        (q, r) = F.div(G)
    else:
        raise OperationNotSupported(f, 'div')
    if retract:
        try:
            (Q, R) = (q.to_ring(), r.to_ring())
        except CoercionFailed:
            pass
        else:
            (q, r) = (Q, R)
    return (per(q), per(r))
