def clean(self):
        """
        Validation to make sure player does not equal opponent for result
        """

        # Make sure both keys are set
        try:
            player = self.cleaned_data['player']
            opponent = self.cleaned_data['opponent']
        except __HOLE__:
            # if not set return cleaned_data to allow for default validation to work
            return self.cleaned_data
        # Make the check
        if player == opponent:
            raise forms.ValidationError("Invalid Result: Player and Opponent cannot be the same person.", 'player_equals_opponent')
        else:
            return self.cleaned_data
dataset/ETHPy150Open jzahedieh/django-tennis-ladder/ladder/forms.py/AddResultForm.clean