use application django-import-export. Here is an example configuration for one of the models:
class ImportExportAdsTypeResource(resources.ModelResource):
class Meta:
model = AdType
import_id_fields = ('name',)
fields = ['name', 'active', 'position', 'categories', 'sites']
sites and categories - is a m2m field. Export works fine, we get such CSV file with the following contents:
name,active,position,sites,categories
Excport CSV test,1,13,1,"19,26"
but when you try to import m2m field are not added. How to import data with m2m relationships?!