0
Does anyone know how I would use the Django-import-export outside the Admin? That is, I wanted the button to export this library in a template of mine, outside of Admin. Which way to the stones?
I tried to
I am trying to export tables to Excel using Django-import-export outside of Admin, that is, in a template. See that in /person/ there is a button to export. This time I created a little project just for that.
So check out my latest commit
https://github.com/rg3915/dj-export/commit/43d7a8cdc719c78a5b83bf91eaed1d635c48ce6a
from import_export.admin import ExportMixin
def export_data_person(request):
e = ExportMixin()
file_format = 'XLSX'
queryset = Person.objects.all()
return e.get_export_data(file_format, queryset)
And when I clicked on the button gave the following error:
AttributeError at /person/export/
'ExportMixin' object has no attribute 'model'
How do I solve this problem?
I am managing to evolve in the solution
def export_data_person(request):
e = ExportMixin()
e.model = Person
file_format = XLSX()
queryset = Person.objects.all()
return e.get_export_data(file_format, queryset)
but it still remains to convert the bytes to download, as it gave the following error:
AttributeError at /person/export/
'bytes' object has no attribute 'get'