#NEWLINE# def validate_base( cls , model ) : #NEWLINE# #INDENT# opts = model . _meta #NEWLINE# if hasattr ( cls , 'raw_id_fields' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'raw_id_fields' , cls . raw_id_fields ) #NEWLINE# for ( idx , field ) in enumerate ( cls . raw_id_fields ) : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'raw_id_fields' , field ) #NEWLINE# if ( not isinstance ( f , ( models . ForeignKey , models . ManyToManyField ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.raw_id_fields[%d]', '%s' must be either a ForeignKey or ManyToManyField." % ( cls . __name__ , idx , field ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if cls . fields : #NEWLINE# #INDENT# check_isseq ( cls , 'fields' , cls . fields ) #NEWLINE# for field in cls . fields : #NEWLINE# #INDENT# check_formfield ( cls , model , opts , 'fields' , field ) #NEWLINE# #UNINDENT# if cls . fieldsets : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( 'Both fieldsets and fields are specified in %s.' % cls . __name__ ) ) #NEWLINE# #UNINDENT# if ( len ( cls . fields ) > len ( set ( cls . fields ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( 'There are duplicate field(s) in %s.fields' % cls . __name__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# if cls . fieldsets : #NEWLINE# #INDENT# check_isseq ( cls , 'fieldsets' , cls . fieldsets ) #NEWLINE# for ( idx , fieldset ) in enumerate ( cls . fieldsets ) : #NEWLINE# #INDENT# check_isseq ( cls , ( 'fieldsets[%d]' % idx ) , fieldset ) #NEWLINE# if ( len ( fieldset ) != 2 ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.fieldsets[%d]' does not have exactly two elements." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# check_isdict ( cls , ( 'fieldsets[%d][1]' % idx ) , fieldset [ 1 ] ) #NEWLINE# if ( 'fields' not in fieldset [ 1 ] ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'fields' key is required in %s.fieldsets[%d][1] field options dict." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# flattened_fieldsets = flatten_fieldsets ( cls . fieldsets ) #NEWLINE# if ( len ( flattened_fieldsets ) > len ( set ( flattened_fieldsets ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( 'There are duplicate field(s) in %s.fieldsets' % cls . __name__ ) ) #NEWLINE# #UNINDENT# for field in flattened_fieldsets : #NEWLINE# #INDENT# check_formfield ( cls , model , opts , ( "fieldsets[%d][1]['fields']" % idx ) , field ) #NEWLINE# #UNINDENT# #UNINDENT# if ( hasattr ( cls , 'form' ) and ( not issubclass ( cls . form , BaseModelForm ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( '%s.form does not inherit from BaseModelForm.' % cls . __name__ ) ) #NEWLINE# #UNINDENT# if hasattr ( cls , 'filter_vertical' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'filter_vertical' , cls . filter_vertical ) #NEWLINE# for ( idx , field ) in enumerate ( cls . filter_vertical ) : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'filter_vertical' , field ) #NEWLINE# if ( not isinstance ( f , models . ManyToManyField ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.filter_vertical[%d]' must be a ManyToManyField." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( cls , 'filter_horizontal' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'filter_horizontal' , cls . filter_horizontal ) #NEWLINE# for ( idx , field ) in enumerate ( cls . filter_horizontal ) : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'filter_horizontal' , field ) #NEWLINE# if ( not isinstance ( f , models . ManyToManyField ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.filter_horizontal[%d]' must be a ManyToManyField." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( cls , 'radio_fields' ) : #NEWLINE# #INDENT# check_isdict ( cls , 'radio_fields' , cls . radio_fields ) #NEWLINE# for ( field , val ) in cls . radio_fields . items ( ) : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'radio_fields' , field ) #NEWLINE# if ( not ( isinstance ( f , models . ForeignKey ) or f . choices ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.radio_fields['%s']' is neither an instance of ForeignKey nor does have choices set." % ( cls . __name__ , field ) ) ) #NEWLINE# #UNINDENT# if ( not ( val in ( HORIZONTAL , VERTICAL ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.radio_fields['%s']' is neither admin.HORIZONTAL nor admin.VERTICAL." % ( cls . __name__ , field ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( cls , 'prepopulated_fields' ) : #NEWLINE# #INDENT# check_isdict ( cls , 'prepopulated_fields' , cls . prepopulated_fields ) #NEWLINE# for ( field , val ) in cls . prepopulated_fields . items ( ) : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'prepopulated_fields' , field ) #NEWLINE# if isinstance ( f , ( models . DateTimeField , models . ForeignKey , models . ManyToManyField ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.prepopulated_fields['%s']' is either a DateTimeField, ForeignKey or ManyToManyField. This isn't allowed." % ( cls . __name__ , field ) ) ) #NEWLINE# #UNINDENT# check_isseq ( cls , ( "prepopulated_fields['%s']" % field ) , val ) #NEWLINE# for ( idx , f ) in enumerate ( val ) : #NEWLINE# #INDENT# get_field ( cls , model , opts , ( "prepopulated_fields['%s'][%d]" % ( field , idx ) ) , f )