def required_field_attrs(self, widget):
 attrs = field_widget_attrs(self, widget)
 if (self.required and ('required' not in attrs)):
  attrs['required'] = 'required'
 return attrs

def required_field_attrs ( self , widget ) : attrs = field_widget_attrs ( self , widget ) if ( self . required and ( 'required' not in attrs ) ) : attrs [ 'required' ] = 'required' return attrs
this function is for use on the base field class .