Skip to content

Commit

Permalink
Fixed #1756 -- Permit selecting no file in a FilePathField with blank…
Browse files Browse the repository at this point in the history
… = True.

Thanks to Adam Endicott for the patch.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3146 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Jun 19, 2006
1 parent 1fc3b32 commit 271083c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/forms/__init__.py
Expand Up @@ -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:
Expand Down

0 comments on commit 271083c

Please sign in to comment.