Total Differential of a Utility Function Subject to a Budget Constraint
In the second term of the intermediate calculation we must find the partial derivative of the entire second parameter of the $f$ function.  Hence
$$dU = \frac{\partial f}{\partial{q_1}}dq_1+\frac{\partial f}{\partial (\frac{y_0-p_1q_1}{p_2})}d(\frac{y_0-p_1q_1}{p_2})$$.  Obviously this is a substitution of $q_2$ into the original total differential derivation you had.  My point is that you tried to do the partial differential of $f$ with respect $q_2$ by assuming that this would equal $$\frac{dq_2}{dq_1}$$ when this may not always be the case.  For the final equation that you have may want to consider the chain rule.  The way you have it, we have defined $$U=f(q_1, q_2)$$ and $$q_2(q_1)=\frac{y_0}{p_2}-\frac{p_1}{p_2}$$  Then according to the chain rule you have $$\frac{dU}{dq_1}=\frac{\partial f}{\partial q_1}\frac{dq_1}{dq_1}+\frac{\partial f}{\partial q_2}\frac{dq_2}{dq_1}$$  Then we evaluate $$\frac{dq_1}{dq_1}=\frac{d}{q_1}q_1=1$$  Then we get $$\frac{dU}{dq_1}=\frac{\partial f}{\partial q_1}+\frac{\partial f}{\partial q_2}\frac{dq_2}{dq_1}$$  Then, $$\frac{dq_2}{dq_1}=-\frac{p_1}{p_2}$$ Finally we end up with $$\frac{dU}{dq_1}=f_1+f_2(-\frac{p_1}{p_2})$$