Adi Ramadhan
Mar 1, 2022

--

you can use resources.ModelResource from import_export packages.

example: Book have author field, a foreign key from Author model.

in admin.py you can add BookResource

class BookResource(resources.ModelResource):

class Meta:

model = Book

fields = ('title', 'description', 'author__name', 'year')

and need to add resource_class in BookAdmin

class BookAdmin(ExportActionMixin, admin.ModelAdmin):

resource_class = BookResource

list_display = ('title', 'description', 'author', 'year')

hope this help

--

--