From 54b331451cb22ee354beadf31ee42cbd714877f0 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Wed, 29 Aug 2018 15:19:32 +0500 Subject: [PATCH] Refs #29689 -- Moved FilePathField choices sorting outside the loop. --- django/forms/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/forms/fields.py b/django/forms/fields.py index 9cc93a46e1c..a9772565253 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -1113,7 +1113,7 @@ class FilePathField(ChoiceField): (self.allow_folders and f.is_dir())) and (self.match is None or self.match_re.search(f.name))): choices.append((f.path, f.name)) - choices.sort(key=operator.itemgetter(1)) + choices.sort(key=operator.itemgetter(1)) self.choices.extend(choices) self.widget.choices = self.choices