diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index ce76a14..878d09c 100644
a
|
b
|
class FileField(Field):
|
213 | 213 | def generate_filename(self, instance, filename): |
214 | 214 | return os.path.join(self.get_directory_name(), self.get_filename(filename)) |
215 | 215 | |
| 216 | def save_form_data(self, instance, data): |
| 217 | if data: |
| 218 | setattr(instance, self.name, data) |
| 219 | |
216 | 220 | def formfield(self, **kwargs): |
217 | 221 | defaults = {'form_class': forms.FileField} |
218 | 222 | # If a file has been provided previously, then the form doesn't require |
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index a202185..6ef44d9 100644
a
|
b
|
True
|
1030 | 1030 | >>> instance.file |
1031 | 1031 | <FieldFile: tests/test3.txt> |
1032 | 1032 | |
| 1033 | # Instance can be edited w/out re-uploading the file and existing file should be preserved. |
| 1034 | |
| 1035 | >>> f = TextFileForm(data={'description': u'New Description'}, instance=instance) |
| 1036 | >>> f.fields['file'].required = False |
| 1037 | >>> f.is_valid() |
| 1038 | True |
| 1039 | >>> instance = f.save() |
| 1040 | >>> instance.description |
| 1041 | u'New Description' |
| 1042 | >>> instance.file |
| 1043 | <FieldFile: tests/test3.txt> |
| 1044 | |
1033 | 1045 | # Delete the current file since this is not done by Django. |
1034 | 1046 | >>> instance.file.delete() |
1035 | 1047 | >>> instance.delete() |