We show that the contact dynamics obtained from the Herglotz variational principle can be described as a constrained nonholonomic or vakonomic ordinary Lagrangian system depending on a dissipative variable with an adequate choice of one constraint. As a consequence we obtain the dynamics of contact nonholonomic and vakonomic systems as ordinary variational calculus with constraints on a Lagrangian with a dissipative variable. The variation of the energy and the other dissipative quantities are also obtained giving the usual results.