def import_row(self, row, instance_loader, using_transactions=True, dry_run=False, **kwargs):
row_result = self.get_row_result_class()()<EOL>try:<EOL><INDENT>self.before_import_row(row, **kwargs)<EOL>instance, new = self.get_or_init_instance(instance_loader, row)<EOL>self.after_import_instance(instance, new, **kwargs)<EOL>if new:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_NEW<EOL><DEDENT>else:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_UPDATE<EOL><DEDENT>row_result.new_record = new<EOL>original = deepcopy(instance)<EOL>diff = self.get_diff_class()(self, original, new)<EOL>if self.for_delete(row, instance):<EOL><INDENT>if new:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_SKIP<EOL>diff.compare_with(self, None, dry_run)<EOL><DEDENT>else:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_DELETE<EOL>self.delete_instance(instance, using_transactions, dry_run)<EOL>diff.compare_with(self, None, dry_run)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>import_validation_errors = {}<EOL>try:<EOL><INDENT>self.import_obj(instance, row, dry_run)<EOL><DEDENT>except ValidationError as e:<EOL><INDENT>import_validation_errors = e.update_error_dict(import_validation_errors)<EOL><DEDENT>if self.skip_row(instance, original):<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_SKIP<EOL><DEDENT>else:<EOL><INDENT>self.validate_instance(instance, import_validation_errors)<EOL>self.save_instance(instance, using_transactions, dry_run)<EOL>self.save_m2m(instance, row, using_transactions, dry_run)<EOL>row_result.object_id = instance.pk<EOL>row_result.object_repr = force_text(instance)<EOL><DEDENT>diff.compare_with(self, instance, dry_run)<EOL><DEDENT>row_result.diff = diff.as_html()<EOL>self.after_import_row(row, row_result, **kwargs)<EOL><DEDENT>except ValidationError as e:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_INVALID<EOL>row_result.validation_error = e<EOL><DEDENT>except Exception as e:<EOL><INDENT>row_result.import_type = RowResult.IMPORT_TYPE_ERROR<EOL>if not isinstance(e, TransactionManagementError):<EOL><INDENT>logger.debug(e, exc_info=e)<EOL><DEDENT>tb_info = traceback.format_exc()<EOL>row_result.errors.append(self.get_error_result_class()(e, tb_info, row))<EOL><DEDENT>return row_result<EOL>
Imports data from ``tablib.Dataset``. Refer to :doc:`import_workflow`
for a more complete description of the whole import process.

:param row: A ``dict`` of the row to import

:param instance_loader: The instance loader to be used to load the row

:param using_transactions: If ``using_transactions`` is set, a transaction
    is being used to wrap the import

:param dry_run: If ``dry_run`` is set, or error occurs, transaction
    will be rolled back.