From 5b8974c7b3cbde2d63ddda8f3bddfa2637af5bb9 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 18 Mar 2008 14:35:05 +0000 Subject: [PATCH] Fixed #5574 -- Serialize a FileField using its filename from the database, not external URL. The problem showed up when reloading the data. Patch from Chris Henderson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7293 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/serializers/base.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index 3c7dcfa02e0..2c92e2afad2 100644 --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -22,10 +22,10 @@ class Serializer(object): Abstract serializer base class. """ - # Indicates if the implemented serializer is only available for + # Indicates if the implemented serializer is only available for # internal Django use. internal_use_only = False - + def serialize(self, queryset, **options): """ Serialize a queryset. @@ -60,8 +60,6 @@ class Serializer(object): """ if isinstance(field, models.DateTimeField): value = getattr(obj, field.name).strftime("%Y-%m-%d %H:%M:%S") - elif isinstance(field, models.FileField): - value = getattr(obj, "get_%s_url" % field.name, lambda: None)() else: value = field.flatten_data(follow=None, obj=obj).get(field.name, "") return smart_unicode(value) @@ -162,9 +160,9 @@ class DeserializedObject(object): return "" % smart_str(self.object) def save(self, save_m2m=True): - # Call save on the Model baseclass directly. This bypasses any + # Call save on the Model baseclass directly. This bypasses any # model-defined save. The save is also forced to be raw. - # This ensures that the data that is deserialized is literally + # This ensures that the data that is deserialized is literally # what came from the file, not post-processed by pre_save/save # methods. models.Model.save(self.object, raw=True)