<s> from django . forms import ValidationError <EOL> from django . forms . models import BaseInlineFormSet <EOL> def validate_is_management ( forms ) : <EOL> """<STR_LIT>""" <EOL> is_management = [ ] <EOL> for form in forms : <EOL> cleaned_data = form . cleaned_data <EOL> if ( <EOL> cleaned_data and <EOL> not cleaned_data . get ( '<STR_LIT>' , False ) <EOL> ) : <EOL> is_management . append ( cleaned_data . get ( '<STR_LIT>' ) ) <EOL> count_management_ip = is_management . count ( True ) <EOL> if is_management and count_management_ip == <NUM_LIT:0> : <EOL> raise ValidationError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> elif is_management and count_management_ip != <NUM_LIT:1> : <EOL> raise ValidationError ( ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) ) <EOL> class NetworkInlineFormset ( BaseInlineFormSet ) : <EOL> def clean ( self ) : <EOL> validate_is_management ( self . forms ) </s>
