1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #28264 -- Made FilePathField sort files and directories when recursive=True.

This commit is contained in:
Srinivas Reddy Thatiparthy
2017-07-16 11:30:03 +05:30
committed by Tim Graham
parent 99e7bba443
commit b306c0c1a3
4 changed files with 13 additions and 5 deletions

View File

@@ -1083,12 +1083,12 @@ class FilePathField(ChoiceField):
if recursive:
for root, dirs, files in sorted(os.walk(self.path)):
if self.allow_files:
for f in files:
for f in sorted(files):
if self.match is None or self.match_re.search(f):
f = os.path.join(root, f)
self.choices.append((f, f.replace(path, "", 1)))
if self.allow_folders:
for f in dirs:
for f in sorted(dirs):
if f == '__pycache__':
continue
if self.match is None or self.match_re.search(f):