def emit_field_changed_events(instance, user, db_table, excluded_fields=None, hidden_fields=None):
 def clean_field(field_name, value):
  '\n        Prepare a field to be emitted in a JSON serializable format.  If\n        `field_name` is a hidden field, return None.\n        '
  if (field_name in hidden_fields):
   return None
  if isinstance(value, Country):
   if value.code:
    return value.code
   else:
    return None
  return value
 excluded_fields = (excluded_fields or [])
 hidden_fields = (hidden_fields or [])
 changed_fields = getattr(instance, '_changed_fields', {})
 for field_name in changed_fields:
  if (field_name not in excluded_fields):
   old_value = clean_field(field_name, changed_fields[field_name])
   new_value = clean_field(field_name, getattr(instance, field_name))
   emit_setting_changed_event(user, db_table, field_name, old_value, new_value)
 if hasattr(instance, '_changed_fields'):
  del instance._changed_fields

def emit_field_changed_events ( instance , user , db_table , excluded_fields = None , hidden_fields = None ) : def clean_field ( field_name , value ) : if ( field_name in hidden_fields ) : return None if isinstance ( value , Country ) : if value . code : return value . code else : return None return value excluded_fields = ( excluded_fields or [ ] ) hidden_fields = ( hidden_fields or [ ] ) changed_fields = getattr ( instance , '_changed_fields' , { } ) for field_name in changed_fields : if ( field_name not in excluded_fields ) : old_value = clean_field ( field_name , changed_fields [ field_name ] ) new_value = clean_field ( field_name , getattr ( instance , field_name ) ) emit_setting_changed_event ( user , db_table , field_name , old_value , new_value ) if hasattr ( instance , '_changed_fields' ) : del instance . _changed_fields
emits a settings changed event for each field that has changed .