Fixed #2611 -- Fixed XML serializer to handle null datetime fields. Thanks for reporting, csdurfee@gmail.com
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3687 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
452847a659
commit
22303d6c7d
|
@ -50,7 +50,11 @@ class Serializer(object):
|
|||
Convert a field's value to a string.
|
||||
"""
|
||||
if isinstance(field, models.DateTimeField):
|
||||
value = getattr(obj, field.name).strftime("%Y-%m-%d %H:%M:%S")
|
||||
value = getattr(obj, field.name)
|
||||
if value is None:
|
||||
value = ''
|
||||
else:
|
||||
value = value.strftime("%Y-%m-%d %H:%M:%S")
|
||||
elif isinstance(field, models.FileField):
|
||||
value = getattr(obj, "get_%s_url" % field.name, lambda: None)()
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue