Creating a custom Export adapter
When creating a custom adapter, the firstthing you'll want to do is import the base class.
from export_app.adapters import BaseAdapter
An export adapter can work from the
ViewSet or both. You can
customize that behaviour with the
works_with property that can one of these 3 values:
Adapters that need field definition will usually work from the
Serializer as it holds
all field-related information.
This is common when using a frontend that has at least a partial data layer.
Adapters that need routing information will usually work from the
ViewSet as it holds
the url and other information like actions.
This is common when using a frontend that cannot map model names to routes.
Of course, sometimes you'll need both types of information, like with the
Some adapters also need to work with the
ViewSet because they will be calling on method
MetadataES6Adapter that export the content produced by calls to the
OPTIONS route of the
Field types mapping
When working with a frontend that has at least a partial data layer, you'll probably want to use some kind of mapping between DRF field types and frontend field types.
There are 2 properties you need to mind in order to do that:
DEFAULT_MAPPINGwhich is the default frontend field type you want to map to.
FIELD_TYPE_MAPPINGwhich is a dictionary. DRF type names are the keys while frontend type names are the values.