I think you want to show that in each ideal class the number of ideals of norm a is equal to the number of ideals of norm a*/D/$a \cdot |D|$. This should follow directly from the following 2 facts.
All primes p dividing /D/ ramify in the ring of integers of Q(root(D)).
The unique ideal of norm /D/ (uniqueness and existence follow from 1, taking a little care about the prime 2) is principal, generated by root (D).
(1). All primes $p$ dividing $|D|$ ramify in the ring of integers of $\mathbb{Q}(\sqrt{D})$.
(2). The unique ideal of norm $|D|$ (uniqueness and existence follow from (1), taking a little care about the prime $2$) is principal, generated by $\sqrt{D}$.
In view of 1.(1) and 2. the map J --> root(D2) * Jthe map $J \rightarrow \sqrt{D} \cdot J$ gives the desired bijection.