Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 2.27 KB

export_workflow.rst

File metadata and controls

57 lines (39 loc) · 2.27 KB

Export workflow

This document describes the export data workflow in detail, with hooks that enable customization of the export process.

Methods highlighted in yellow in the sequence diagram indicate public methods which can be overridden.

Export workflow sequence diagram

The ~import_export.resources.Resource.export method retrieves a QuerySet from the database and formats into a tablib.Dataset.

Various hook methods are defined to allow you to customize the export data.

This is what happens when the method is invoked:

  1. The ~import_export.resources.Resource.export method is passed an optional queryset parameter. The kwargs dict can hold additional information used to create the export, for example if called from the Admin UI.
  2. The ~import_export.resources.Resource.before_export hook is called.
  3. If no QuerySet has been passed, then ~import_export.resources.Resource.get_queryset method is called.
  4. The ~import_export.resources.Resource.filter_export hook is called. You can override this method to modify the queryset for export.
  5. For each instance in the QuerySet, ~import_export.resources.Resource.export_resource is called (with the instance passed as a parameter).
  6. For each field defined in ~import_export.options.ResourceOptions.fields:
    • ~import_export.resources.Resource.export_field is called with the field and instance as parameters.
    • If a dehydrate<advanced_data_manipulation_on_export> method is defined on the Resource, then this method is called to extract the field value, Otherwise ~import_export.fields.Field.export is called for each defined field, with the instance passed as a parameter.
    • ~import_export.fields.Field.get_value is called with the instance to retrieve the export value from the instance.export
    • The field's widget ~import_export.widgets.Widget.render method is called to retrieve the export value.
  7. Each value is appended to a tablib.Dataset.
  8. The tablib.Dataset is returned from ~import_export.resources.Resource.export.