@transaction.atomic
def override_field_for_ccx(ccx, block, name, value):
 field = block.fields[name]
 value_json = field.to_json(value)
 serialized_value = json.dumps(value_json)
 override_has_changes = False
 clean_ccx_key = _clean_ccx_key(block.location)
 override = get_override_for_ccx(ccx, block, (name + '_instance'))
 if override:
  override_has_changes = (serialized_value != override.value)
 if (not override):
  (override, created) = CcxFieldOverride.objects.get_or_create(ccx=ccx, location=block.location, field=name, defaults={'value': serialized_value})
  if created:
   _get_overrides_for_ccx(ccx).setdefault(clean_ccx_key, {})[(name + '_id')] = override.id
  else:
   override_has_changes = (serialized_value != override.value)
 if override_has_changes:
  override.value = serialized_value
  override.save()
 _get_overrides_for_ccx(ccx).setdefault(clean_ccx_key, {})[name] = value_json
 _get_overrides_for_ccx(ccx).setdefault(clean_ccx_key, {})[(name + '_instance')] = override

@ transaction . atomic def override_field_for_ccx ( ccx , block , name , value ) : field = block . fields [ name ] value_json = field . to_json ( value ) serialized_value = json . dumps ( value_json ) override_has_changes = False clean_ccx_key = _clean_ccx_key ( block . location ) override = get_override_for_ccx ( ccx , block , ( name + '_instance' ) ) if override : override_has_changes = ( serialized_value != override . value ) if ( not override ) : ( override , created ) = CcxFieldOverride . objects . get_or_create ( ccx = ccx , location = block . location , field = name , defaults = { 'value' : serialized_value } ) if created : _get_overrides_for_ccx ( ccx ) . setdefault ( clean_ccx_key , { } ) [ ( name + '_id' ) ] = override . id else : override_has_changes = ( serialized_value != override . value ) if override_has_changes : override . value = serialized_value override . save ( ) _get_overrides_for_ccx ( ccx ) . setdefault ( clean_ccx_key , { } ) [ name ] = value_json _get_overrides_for_ccx ( ccx ) . setdefault ( clean_ccx_key , { } ) [ ( name + '_instance' ) ] = override
overrides a field for the ccx .