GenericImporter

class data_importer.importers.generic.GenericImporter(source=None, *args, **kwargs)

An implementation of BaseImporter that sets the right reader by file extension. Probably the best choice for almost all implementation cases

class Meta

Importer configurations

GenericImporter.clean()

Custom clean method

GenericImporter.clean_field(field_name, value)

User default django field validators to clean content and run custom validates

GenericImporter.clean_row(row_values)

Custom clean method for full row data

GenericImporter.cleaned_data

Return tupla with data cleaned

GenericImporter.errors

Show errors catch by clean methods

GenericImporter.exclude_fields()

Exclude fields from Meta.exclude

GenericImporter.get_error_message(error, row=None, error_type=None)
GenericImporter.get_reader_class()

Gets the right file reader class by source file extension

GenericImporter.get_source_file_extension()

Gets the source file extension. Used to choose the right reader

GenericImporter.is_valid()

Clear content and return False if have errors

GenericImporter.load_descriptor()

Set fields from descriptor file

GenericImporter.meta

Is same to use .Meta

GenericImporter.post_clean()

Excuted after all clean method

GenericImporter.post_save_all_lines()

End exection

GenericImporter.pre_clean()

Executed before all clean methods Important: pre_clean dont have cleaned_data content

GenericImporter.pre_commit()

Executed before commit multiple register

GenericImporter.process_row(row, values)

Read clean functions from importer and return tupla with row number, field and value

GenericImporter.save(instance=None)

Save all contents DONT override this method

GenericImporter.set_reader()
GenericImporter.source

Return source opened

GenericImporter.start_fields()

Initial function to find fields or headers values This values will be used to process clean and save method If this method not have fields and have Meta.model this method will use model fields to populate content without id

GenericImporter.to_unicode(bytestr)

Receive string bytestr and try to return a utf-8 string.