181 | | def save_file(self, new_data, new_object, original_object, change, rel, |
182 | | save=True): |
183 | | upload_field_name = self.name + '_file' |
184 | | if new_data.get(upload_field_name, False): |
185 | | if rel: |
186 | | file = new_data[upload_field_name][0] |
187 | | else: |
188 | | file = new_data[upload_field_name] |
189 | | |
190 | | # Backwards-compatible support for files-as-dictionaries. |
191 | | # We don't need to raise a warning because the storage backend will |
192 | | # do so for us. |
193 | | try: |
194 | | filename = file.name |
195 | | except AttributeError: |
196 | | filename = file['filename'] |
197 | | filename = self.get_filename(filename) |
198 | | |
199 | | getattr(new_object, self.attname).save(filename, file, save) |
200 | | |