Taking on what contract? The Rams had to eat the dead money so all Detroit is left with is the following:
2021 Cap Hit $27.825M $0 Dead Money
2022 Cap Hit $25.5M $0 Dead Money
2023 Cap Hit $25M $0 Dead Money
2024 Cap Hit $26M $0 Dead Money
So what Detroit got was a former #1 overall QB whose cap hits are below market value for QB's with absolutely ZERO dead money.....oh, and they also got back a 3rd round pick in 2021, a 1st round pick in 2022 & 2023.....so I would say Detroit made out and is fully capable of now trading Goff to a QB needy team for additional draft picks without any dead money penalty against their cap.
As for Stafford, he had $19M in dead money remaining on his deal which Detroit will get hit with but based on his 2021 cap hit of $33M, Detroit actually will save $14M against the cap in 2021 by having traded Stafford.