<s> from django import forms <EOL> from ladder . models import Result , Player <EOL> class AddResultForm ( forms . ModelForm ) : <EOL> result = forms . IntegerField ( min_value = <NUM_LIT:0> , max_value = <NUM_LIT:8> , label = '<STR_LIT>' ) <EOL> def __init__ ( self , ladder , * args , ** kwargs ) : <EOL> super ( AddResultForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . fields [ '<STR_LIT>' ] . queryset = self . fields [ '<STR_LIT>' ] . queryset = Player . objects . filter ( league__ladder = ladder ) <EOL> class Meta ( object ) : <EOL> model = Result <EOL> exclude = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def clean ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> player = self . cleaned_data [ '<STR_LIT>' ] <EOL> opponent = self . cleaned_data [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> return self . cleaned_data <EOL> if player == opponent : <EOL> raise forms . ValidationError ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> else : <EOL> return self . cleaned_data </s>
