#NEWLINE# def validate( self , value_list , model_instance ) : #NEWLINE# #INDENT# ' We want to override the default validate method from django.db.fields.Field, because it\n            is only designed to deal with a single choice from the user.\n        ' #NEWLINE# if ( not self . editable ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if self . choices : #NEWLINE# #INDENT# valid_values = [ ] #NEWLINE# for choice in self . choices : #NEWLINE# #INDENT# if isinstance ( choice [ 0 ] , ( list , tuple ) ) : #NEWLINE# #INDENT# for optgroup_choice in choice [ 0 ] : #NEWLINE# #INDENT# valid_values . append ( optgroup_choice [ 0 ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# valid_values . append ( choice [ 0 ] ) #NEWLINE# #UNINDENT# #UNINDENT# for value in value_list : #NEWLINE# #INDENT# if ( value not in valid_values ) : #NEWLINE# #INDENT# raise ValidationError ( ( self . error_messages [ 'invalid_choice' ] % value ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( value_list is None ) and ( not self . null ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'null' ] ) #NEWLINE# #UNINDENT# if ( ( not self . blank ) and ( not value_list ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'blank' ] ) #NEWLINE# #UNINDENT# for value in value_list : #NEWLINE# #INDENT# self . item_field_type . clean ( value , model_instance )