def form_valid_bridge(self, form, field, model, related_field, error_message):
<EOL>external = form.cleaned_data[field]<EOL>object_edit = model.objects.get(pk=form.instance.pk)<EOL>if object_edit.external == external:<EOL><INDENT>answer = super(GenUpdateBridge, self).form_valid(form)<EOL><DEDENT>else:<EOL><INDENT>related_object = get_external_model(model).objects.filter(**{<EOL>"<STR_LIT>": external.pk,<EOL>"<STR_LIT>".format(related_field): False<EOL>}).exclude(**{<EOL>"<STR_LIT:{}>".format(related_field): form.instance,<EOL>}).first()<EOL>if not related_object:<EOL><INDENT>try:<EOL><INDENT>with transaction.atomic():<EOL><INDENT>result = super(GenUpdateBridge, self).form_valid(form)<EOL>field = object_edit.external<EOL>setattr(field, related_field, None)<EOL>field.save()<EOL>setattr(external, related_field, form.instance)<EOL>external.save()<EOL><DEDENT>answer = HttpResponseRedirect(self.get_success_url())<EOL><DEDENT>except CodenerixException:<EOL><INDENT>answer = super(GenUpdateBridge, self).form_invalid(form)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>errors = form._errors.setdefault(field, ErrorList())<EOL>errors.append(error_message[<NUM_LIT:0>])<EOL>answer = super(GenUpdateBridge, self).form_invalid(form)<EOL><DEDENT><DEDENT>return answer<EOL>
call from form_valid.
@form: it is form of form_valid (type: form)
@field: name of the form field referring to the brigde (type: string)
@model: form's model (type class)
@related_field: name of the related_name of the brigde (type: string)
@error_message: list of message errors (type list)
    one item, example:
    ["The selected entry is not available anymore, please, try again!", ]