BaseImporter

class data_importer.importers.base.BaseImporter(source=None, *args, **kwargs)

Base Importer method to create simples importes CSV files.

set_reader: can be override to create new importers files

class Meta

Importer configurations

BaseImporter.clean()

Custom clean method

BaseImporter.clean_field(field_name, value)

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

BaseImporter.clean_row(row_values)

Custom clean method for full row data

BaseImporter.cleaned_data

Return tupla with data cleaned

BaseImporter.errors

Show errors catch by clean methods

BaseImporter.exclude_fields()

Exclude fields from Meta.exclude

BaseImporter.is_valid()

Clear content and return False if have errors

BaseImporter.load_descriptor()

Set fields from descriptor file

BaseImporter.meta

Is same to use .Meta

BaseImporter.post_clean()

Excuted after all clean method

BaseImporter.post_save_all_lines()

End exection

BaseImporter.pre_clean()

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

BaseImporter.pre_commit()

Executed before commit multiple register

BaseImporter.process_row(row, values)

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

BaseImporter.save(instance=None)

Save all contents DONT override this method

BaseImporter.set_reader()

Method responsable to convert file content into a list with same values that have fields

fields: [‘myfield1’, ‘myfield2’]

response: [[‘value_myfield1’, ‘value_myfield2’],
[‘value2_myfield1’, ‘value2_myfield2’]]
BaseImporter.source

Return source opened

BaseImporter.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

static BaseImporter.to_unicode(bytestr)

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