diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-06-19 12:30:43 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2006-06-19 12:30:43 +0000 |
| commit | 271083cf7c63155ae7221e63e6d198acbbe802e5 (patch) | |
| tree | 5128e17d9456569539aecf8fa9ae30c5dde937da /django/forms/__init__.py | |
| parent | 1fc3b3229a9b137f05a0a49bdc726f8c91317174 (diff) | |
Fixed #1756 -- Permit selecting no file in a FilePathField with blank = True.
Thanks to Adam Endicott for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3146 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/__init__.py')
| -rw-r--r-- | django/forms/__init__.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/forms/__init__.py b/django/forms/__init__.py index a730291b45..fab7a6da7a 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -898,10 +898,11 @@ class FilePathField(SelectField): "A SelectField whose choices are the files in a given directory." def __init__(self, field_name, path, match=None, recursive=False, is_required=False, validator_list=None): import os + from django.db.models import BLANK_CHOICE_DASH if match is not None: import re match_re = re.compile(match) - choices = [] + choices = not is_required and BLANK_CHOICE_DASH[:] or [] if recursive: for root, dirs, files in os.walk(path): for f in files: |
