Code

Opened 8 years ago

Closed 8 years ago

#2611 closed defect (fixed)

XML serialization does not handle null datetime fields

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

Description (last modified by adrian)

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")

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by adrian

  • Description modified (diff)

comment:2 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [3687]) Fixed #2611 -- Fixed XML serializer to handle null datetime fields. Thanks for reporting, csdurfee@…

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.