How to format export fields with numeric values in django-import-export

545 views Asked by At

Using django-import-export to export data from django admin in excel xlsx format.

However, numeric fields export as text in excel.

enter image description here

I'd like to export correctly as numeric fields.

Documentation has a sample syntax for BooleanWidget, but it's not working, it replaces the value with the object __str__ value, instead of converting the value to a number.

1

There are 1 answers

0
Renato Chencinski On BEST ANSWER

Found out I have to instantiate the widget, not reference the class (Use parenthesis at the end)

from import_export import widgets

enrolled = fields.Field(widget=widgets.NumberWidget())`

Created a pull request to fix sample usage.