use application django-import-export. Here is an example configuration for one of the models:
class ImportExportAdsTypeResource(resources.ModelResource):
cla
django-import-export has it's own widgets to handle models relationships:
from import_export import fields, resources
from import_export.widgets import ManyToManyWidget
class ImportExportAdsTypeResource(resources.ModelResource):
categories = fields.Field(widget=ManyToManyWidget(Category))
sites = fields.Field(widget=ManyToManyWidget(Site))
class Meta:
model = AdType
import_id_fields = ('name',)
fields = ['name', 'active', 'position', 'categories', 'sites']
Check here for other widgets: django-import-export Widgets