I understand what you're trying to do here and while it works it's not the best way to do this. It's not your fault of course, it's just the `update_invites` that needs some love. I suggest the following:

1. We rename `update_invites` to `redeem_invite` which a more proper name
2. We check here is `request.session.get('invite-code')` exists and only if it exists we call `redeem_invite` with parameters `profile` and `code`, where `code` stores  `request.session.get('invite-code')`
3. We clean up / rewrite `redeem_invite` accordingly.