The pattern profile = Profile.objects.get(user=user) was useful when user had a ForiegnKey relationship. Since #2749, it has been unnecessary. Switching these to user.profile has some benefits:
In most cases, it reduces the lines of code
It removes a possible mismatch between user.profile and the stand-alone Profile object, which could introduce bugs
In some cases, importing Profile is no longer needed, which will reduce the code changes when moving Profile to privaterelay.
The pattern
profile = Profile.objects.get(user=user)
was useful whenuser
had aForiegnKey
relationship. Since #2749, it has been unnecessary. Switching these touser.profile
has some benefits:user.profile
and the stand-aloneProfile
object, which could introduce bugsProfile
is no longer needed, which will reduce the code changes when movingProfile
toprivaterelay
.