diff --git a/db/models/fields/files.py b/db/models/fields/files.py
index e631f17..f3bfda6 100644
a
|
b
|
class FileDescriptor(object):
|
168 | 168 | # in __set__. |
169 | 169 | file = instance.__dict__[self.field.name] |
170 | 170 | |
| 171 | if file is None: |
| 172 | return None |
| 173 | |
171 | 174 | # If this value is a string (instance.file = "path/to/file") or None |
172 | 175 | # then we simply wrap it with the appropriate attribute class according |
173 | 176 | # to the file field. [This is FieldFile for FileFields and |
… |
… |
class FileDescriptor(object):
|
175 | 178 | # subclasses might also want to subclass the attribute class]. This |
176 | 179 | # object understands how to convert a path to a file, and also how to |
177 | 180 | # handle None. |
178 | | if isinstance(file, six.string_types) or file is None: |
| 181 | if isinstance(file, six.string_types): |
179 | 182 | attr = self.field.attr_class(instance, self.field, file) |
180 | 183 | instance.__dict__[self.field.name] = attr |
181 | 184 | |
… |
… |
class FileField(Field):
|
238 | 241 | def get_prep_value(self, value): |
239 | 242 | "Returns field's value prepared for saving into a database." |
240 | 243 | # Need to convert File objects provided via a form to unicode for database insertion |
241 | | if value is None: |
| 244 | if (value is None) or not value: |
242 | 245 | return None |
243 | 246 | return six.text_type(value) |
244 | 247 | |