Django import-export: only export
Asked Answered
R

3

12

I'm using the third party library Django-import-export for importing/exporting data.

It's working properly but I only want the export functionality (not import one).

How could I use only export without import?

Roshelle answered 25/3, 2015 at 9:59 Comment(1)
This is not a question.Schroeder
S
34
from import_export.admin import ExportMixin

class BookAdmin(ExportMixin, admin.ModelAdmin):
Suwannee answered 23/4, 2015 at 14:33 Comment(3)
Just in case someone runs into my same mistake, the order in which you inherit the ExportMixin is relevant (first the mixing, then the modeladmin, just as indicated by user2947136). For some reason i was writing it in reverse and wasn't working.Terrigenous
Just in case someone has the same confusion as I had: admin.ModelAdmin is a subclass of django.contrib or, in full, django.contrib.admin.ModelAdmin and not a subclass of import_export.admin: See here.Alleris
Additional FYI, ExportMixin comes from here from import_export.admin import ExportMixinPitiless
W
5

If you want the action of Export Selected Books, you can use

class BookAdmin(ExportActionModelAdmin,admin.ModelAdmin):
Wagoner answered 14/10, 2015 at 11:57 Comment(0)
W
2

As your question is not really described, I can only guess, that you want to remove the "import" button in the Admin view?

As described here you have to set the ExportMixin on your ModelAdmin. So it looks something like this

class BookAdmin(ExportMixin, ModelAdmin):
Wimple answered 25/3, 2015 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.