Commits

Matthew Schinckel committed 71bedd9

Django 1.4 changes the datetime serialisation format.
We need to have a ' ', not a 'T' for legacy clients.

  • Participants
  • Parent commits 7690535

Comments (0)

Files changed (1)

File rest_api/serializers/json.py

 from datetime import date, time, datetime, timedelta
 from decimal import Decimal
 
-
+class JSONEncoder(DjangoJSONEncoder):
+    def default(self, o):
+        if isinstance(o, datetime):
+            return super(JSONEncoder, self).default(o).replace('T', ' ')
+        return super(JSONEncoder, self).default(o)
+    
 def serialize(queryset, fields=None, exclude=None, **kwargs):
     """
     Serialize an object or list or objects.
         return data
     
     # We want to make null DecimalFields into "" ?
-    return DjangoJSONEncoder(**kwargs).encode(data), 'application/json'
+    return JSONEncoder(**kwargs).encode(data), 'application/json'
 
 
 def deserialize(stream):