Skip to content

Commit

Permalink
Cast UUID to string, because XlsxWriter can't write it
Browse files Browse the repository at this point in the history
  • Loading branch information
timmartin committed Mar 7, 2018
1 parent 4223774 commit 5246238
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions explorer/exporters.py
@@ -1,6 +1,7 @@
from django.db import DatabaseError
from django.core.serializers.json import DjangoJSONEncoder
import json
import uuid
import string
import sys
from datetime import datetime
Expand Down Expand Up @@ -122,8 +123,10 @@ def _get_output(self, res, **kwargs):
col = 0
for data_row in res.data:
for data in data_row:
# xlsxwriter can't handle timezone-aware datetimes, so we help out here and just cast it to a string
if isinstance(data, datetime):
# xlsxwriter can't handle timezone-aware datetimes or
# UUIDs, so we help out here and just cast it to a
# string
if isinstance(data, datetime) or isinstance(data, uuid.UUID):
data = str(data)
# JSON and Array fields
if isinstance(data, dict) or isinstance(data, list):
Expand Down

0 comments on commit 5246238

Please sign in to comment.