#NEWLINE# def validate( cls , model ) : #NEWLINE# #INDENT# '\n    Does basic ModelAdmin option validation. Calls custom validation\n    classmethod in the end if it is provided in cls. The signature of the\n    custom validation classmethod should be: def validate(cls, model).\n    ' #NEWLINE# models . get_apps ( ) #NEWLINE# opts = model . _meta #NEWLINE# validate_base ( cls , model ) #NEWLINE# if hasattr ( cls , 'list_display' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'list_display' , cls . list_display ) #NEWLINE# for ( idx , field ) in enumerate ( cls . list_display ) : #NEWLINE# #INDENT# if ( not callable ( field ) ) : #NEWLINE# #INDENT# if ( not hasattr ( cls , field ) ) : #NEWLINE# #INDENT# if ( not hasattr ( model , field ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# opts . get_field ( field ) #NEWLINE# #UNINDENT# except models . FieldDoesNotExist : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( '%s.list_display[%d], %r is not a callable or an attribute of %r or found in the model %r.' % ( cls . __name__ , idx , field , cls . __name__ , model . _meta . object_name ) ) ) #NEWLINE# #UNINDENT# f = fetch_attr ( cls , model , opts , ( 'list_display[%d]' % idx ) , field ) #NEWLINE# if isinstance ( f , models . ManyToManyField ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.list_display[%d]', '%s' is a ManyToManyField which is not supported." % ( cls . __name__ , idx , field ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( cls , 'list_display_links' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'list_display_links' , cls . list_display_links ) #NEWLINE# for ( idx , field ) in enumerate ( cls . list_display_links ) : #NEWLINE# #INDENT# fetch_attr ( cls , model , opts , ( 'list_display_links[%d]' % idx ) , field ) #NEWLINE# if ( field not in cls . list_display ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.list_display_links[%d]'refers to '%s' which is not defined in 'list_display'." % ( cls . __name__ , idx , field ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if hasattr ( cls , 'list_filter' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'list_filter' , cls . list_filter ) #NEWLINE# for ( idx , field ) in enumerate ( cls . list_filter ) : #NEWLINE# #INDENT# get_field ( cls , model , opts , ( 'list_filter[%d]' % idx ) , field ) #NEWLINE# #UNINDENT# #UNINDENT# if ( hasattr ( cls , 'list_per_page' ) and ( not isinstance ( cls . list_per_page , int ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.list_per_page' should be a integer." % cls . __name__ ) ) #NEWLINE# #UNINDENT# if hasattr ( cls , 'search_fields' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'search_fields' , cls . search_fields ) #NEWLINE# #UNINDENT# if cls . date_hierarchy : #NEWLINE# #INDENT# f = get_field ( cls , model , opts , 'date_hierarchy' , cls . date_hierarchy ) #NEWLINE# if ( not isinstance ( f , ( models . DateField , models . DateTimeField ) ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.date_hierarchy is neither an instance of DateField nor DateTimeField." % cls . __name__ ) ) #NEWLINE# #UNINDENT# #UNINDENT# if cls . ordering : #NEWLINE# #INDENT# check_isseq ( cls , 'ordering' , cls . ordering ) #NEWLINE# for ( idx , field ) in enumerate ( cls . ordering ) : #NEWLINE# #INDENT# if ( ( field == '?' ) and ( len ( cls . ordering ) != 1 ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.ordering' has the random ordering marker '?', but contains other fields as well. Please either remove '?' or the other fields." % cls . __name__ ) ) #NEWLINE# #UNINDENT# if ( field == '?' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if field . startswith ( '-' ) : #NEWLINE# #INDENT# field = field [ 1 : ] #NEWLINE# #UNINDENT# if ( '__' in field ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# get_field ( cls , model , opts , ( 'ordering[%d]' % idx ) , field ) #NEWLINE# #UNINDENT# #UNINDENT# for attr in ( 'save_as' , 'save_on_top' ) : #NEWLINE# #INDENT# if ( not isinstance ( getattr ( cls , attr ) , bool ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.%s' should be a boolean." % ( cls . __name__ , attr ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if hasattr ( cls , 'inlines' ) : #NEWLINE# #INDENT# check_isseq ( cls , 'inlines' , cls . inlines ) #NEWLINE# for ( idx , inline ) in enumerate ( cls . inlines ) : #NEWLINE# #INDENT# if ( not issubclass ( inline , BaseModelAdmin ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.inlines[%d]' does not inherit from BaseModelAdmin." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# if ( not inline . model ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'model' is a required attribute of '%s.inlines[%d]'." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# if ( not issubclass ( inline . model , models . Model ) ) : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( "'%s.inlines[%d].model' does not inherit from models.Model." % ( cls . __name__ , idx ) ) ) #NEWLINE# #UNINDENT# validate_base ( inline , opts . model ) #NEWLINE# validate_inline ( inline )