Django

Code

Changeset 7906

Show
Ignore:
Timestamp:
07/12/08 15:43:28 (4 months ago)
Author:
jacob
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/fields/__init__.py

    r7883 r7906  
    836836        upload_field_name = self.get_manipulator_field_names('')[0] 
    837837        if new_data.get(upload_field_name, False): 
    838             func = getattr(new_object, 'save_%s_file' % self.name) 
    839838            if rel: 
    840839                file = new_data[upload_field_name][0] 
    841840            else: 
    842841                file = new_data[upload_field_name] 
     842 
     843            if not file: 
     844                return 
    843845 
    844846            # Backwards-compatible support for files-as-dictionaries. 
     
    850852                file_name = file['filename'] 
    851853 
     854            func = getattr(new_object, 'save_%s_file' % self.name) 
    852855            func(file_name, file, save) 
    853856