django-import-export / django-import-export

Django application and library for importing and exporting data with admin integration.

Home Page:https://django-import-export.readthedocs.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to export to xls with UUIDs

petersenpeter opened this issue · comments

Describe the bug
In the admin interface in the list view. I am not able to export to xls. When I click the button I get below error:

Traceback (most recent call last):
  File "/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 232, in inner
    return view(request, *args, **kwargs)
  File "/lib/python3.9/site-packages/import_export/admin.py", line 830, in export_action
    export_data = self.get_export_data(
  File "/lib/python3.9/site-packages/import_export/admin.py", line 774, in get_export_data
    export_data = file_format.export_data(
  File "/lib/python3.9/site-packages/import_export/formats/base_formats.py", line 93, in export_data
    return dataset.export(self.get_title(), **kwargs)
  File "/lib/python3.9/site-packages/tablib/core.py", line 436, in export
    return fmt.export_set(self, **kwargs)
  File "/lib/python3.9/site-packages/tablib/formats/_xls.py", line 47, in export_set
    cls.dset_sheet(dataset, ws)
  File "/lib/python3.9/site-packages/tablib/formats/_xls.py", line 149, in dset_sheet
    ws.write(i, j, col)
  File "/lib/python3.9/site-packages/xlwt/Worksheet.py", line 1088, in write
    self.row(r).write(c, label, style)
  File "/lib/python3.9/site-packages/xlwt/Row.py", line 254, in write
    raise Exception("Unexpected data type %r" % type(label))
Exception: Unexpected data type <class 'uuid.UUID'>

Versions (please complete the following information):

  • Django Import Export: 3.3.7
  • Python 3.9.18
  • Django 3.2.23

You can see from the stacktrace this this error is coming from the xlwt package which has been deprecated since 2016.
I suggest export to xlsx if you can.

Closing because we cannot provide a fix for this issue.

Hi Matthew

Thanks for your reply nonetheless and the suggestion.