First degree: During a first-degree education, you can deduct your rent as special expenses (Sonderausgaben). The requirements mentioned below regarding a secondary residence do not apply.
Second degree: If your student apartment is your secondary residence (Zweitwohnsitz), you can deduct its entire rent as study costs / Werbungskosten.
You can also deduct journeys between your student apartment and your main place of residence (e.g. your parents’ house) as home journeys; at 30 cents per kilometer, both ways!