def METHOD_NAME():
    user = form.cleaned_data['user']
    try:
        tm = TeamMembership.objects.get(
            user=request.user, team__contest=request.contest
        )
        if user != tm.team.user:
            raise forms.ValidationError(
                _("You can't submit a solution for another team!")
            )
        return user
    except TeamMembership.DoesNotExist:
        raise forms.ValidationError(_("Team does not exist"))