mirror of
https://github.com/django/django.git
synced 2025-07-19 03:05:32 +00:00
Fixed #7048 -- Added ClearableFileInput widget to clear file fields. Thanks for report and patch, jarrow and Carl Meyer.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a64e96c227
commit
392d992f82
17 changed files with 357 additions and 30 deletions
|
@ -282,7 +282,15 @@ class FileField(Field):
|
|||
return os.path.join(self.get_directory_name(), self.get_filename(filename))
|
||||
|
||||
def save_form_data(self, instance, data):
|
||||
if data:
|
||||
# Important: None means "no change", other false value means "clear"
|
||||
# This subtle distinction (rather than a more explicit marker) is
|
||||
# needed because we need to consume values that are also sane for a
|
||||
# regular (non Model-) Form to find in its cleaned_data dictionary.
|
||||
if data is not None:
|
||||
# This value will be converted to unicode and stored in the
|
||||
# database, so leaving False as-is is not acceptable.
|
||||
if not data:
|
||||
data = ''
|
||||
setattr(instance, self.name, data)
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue