Author: jacob
Date: 2008-07-12 15:43:28 -0500 (Sat, 12 Jul 2008)
New Revision: 7906
Modified:
django/trunk/django/db/models/fields/__init__.py
Log:
Fixed #7667: fixied FileField.save_file for inline related objects. This is
really just papering over a bigger problem that should get fixed either by
newforms-admin or the file-storage refactoring, but this fix makes the admin
work until either of those things happen. Thanks, oggy.
Modified: django/trunk/django/db/models/fields/__init__.py
===================================================================
--- django/trunk/django/db/models/fields/__init__.py 2008-07-12 20:43:15 UTC
(rev 7905)
+++ django/trunk/django/db/models/fields/__init__.py 2008-07-12 20:43:28 UTC
(rev 7906)
@@ -835,12 +835,14 @@
def save_file(self, new_data, new_object, original_object, change, rel,
save=True):
upload_field_name = self.get_manipulator_field_names('')[0]
if new_data.get(upload_field_name, False):
- func = getattr(new_object, 'save_%s_file' % self.name)
if rel:
file = new_data[upload_field_name][0]
else:
file = new_data[upload_field_name]
+ if not file:
+ return
+
# Backwards-compatible support for files-as-dictionaries.
# We don't need to raise a warning because Model._save_FIELD_file
will
# do so for us.
@@ -849,6 +851,7 @@
except AttributeError:
file_name = file['filename']
+ func = getattr(new_object, 'save_%s_file' % self.name)
func(file_name, file, save)
def get_directory_name(self):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---