Skip to content

Commit

Permalink
Merge pull request #323 from timmartin/uuid
Browse files Browse the repository at this point in the history
Cast UUID to string, because XlsxWriter can't write it
  • Loading branch information
chrisclark committed Apr 2, 2018
2 parents ea6bd4b + 5246238 commit 94423c1
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 94423c1

Please sign in to comment.