You can set `profile = request.user.userprofile` in line 70 and skip the `else` entirely.