mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	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:
		| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user