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:
Adrian Holovaty 2006-08-31 04:11:46 +00:00
parent 452847a659
commit 22303d6c7d
1 changed files with 29 additions and 25 deletions

View File

@ -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: