Skip to main content

Export objects of resource.

GET 

/:api_prefix/:service_name/admin/:resource_name/export

Returns the resource objects matching the current list filters as a downloadable document. It takes the filter and order_by parameters of the resource list endpoint and answers them the same way, so the export contains exactly the rows the list shows, in the order it shows them, including the row-level restrictions the resource puts on its queryset.

The response carries a Content-Disposition: attachment header with the file name (<resource_name>.<format>). Clients reading the file name from JavaScript need the header exposed via CORS (Access-Control-Expose-Headers).

Optional endpoint. The backend switches the export on per resource (export_enabled); it is off by default. Resources that do not export return HTTP 404 for this path. The export button itself is signalled in the list view schema through the list_actions slot with an action of type export.

Formats​

The format query parameter is resolved by content negotiation against the formats the resource offers. csv is built in; xlsx requires the optional openpyxl dependency on the backend. Requesting a format the resource does not offer returns HTTP 404; omitting the parameter serves the first offered format.

Columns​

Without fields the resource exports its whole configured column set. fields narrows it down and defines the column order; a field the resource does not export is rejected with HTTP 422. Column headers are the verbose names of the model fields.

Limits and safety​

  • Exports above a fixed row limit (10 000) are rejected with HTTP 422 - building them synchronously would block the worker. Answering a bigger export in the background instead is Premium, provided by the paid habarico-enterprise package.
  • Reading the resource is required; a resource the user may not read returns HTTP 405 for this path.
  • Values a spreadsheet application would evaluate as a formula are escaped by the renderers (CSV / XLSX injection).

Request​

Responses​

The exported document.