Opened 18 years ago

Last modified 18 years ago

#2611 closed defect

XML serialization does not handle null datetime fields — at Version 1

Reported by: csdurfee@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adrian Holovaty)

If you try to serialize a Django object to XML (JSON serialization is fine) that has a null datetime field, you get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\python24\lib\site-packages\django\core\serializers\__init__.py", line
 55, in serialize
    s.serialize(queryset, **options)
  File "c:\python24\lib\site-packages\django\core\serializers\base.py", line 39,
 in serialize
    self.handle_field(obj, field)
  File "c:\python24\lib\site-packages\django\core\serializers\xml_serializer.py"
, line 61, in handle_field
    value = self.get_string_value(obj, field)
  File "c:\python24\lib\site-packages\django\core\serializers\base.py", line 53,
 in get_string_value
    value = getattr(obj, field.name).strftime("%Y-%m-%d %H:%M:%S")

Change History (1)

comment:1 by Adrian Holovaty, 18 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top