The D7 chord usually goes with G. If you make a G chord with 3 fingers, as above, your fingers are making a large triangle.
To change to D7, you just have to contract your fingers to a smaller triangle, sliding your 3rd finger back a fret, and bringing the other two fingers in to make the D7 shape, as below. Make sure you don't lift your fingers up more than you need to- this should be a smooth change.
To change back to G, open out your fingers again, sliding your 3rd finger back to the 3rd fret. Here's the diagram for D7* (notice how it's different from D):