'Returns the membership for the given user and team, or throws Http404 if it does not exist.'

def get_membership(self, username, team):

    try:
        return CourseTeamMembership.objects.get(user__username=username, team=team)
    except CourseTeamMembership.DoesNotExist:
        raise Http404
