diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-12-02 01:03:00 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-12-02 01:03:00 +0000 |
| commit | d7391648d4035dbce70f11f131cf90587d122560 (patch) | |
| tree | 1f444afd5221588e69ce3dcc848010c922a8b814 | |
| parent | a607d9d34546a4ff9313d431e275ed0bf365d42a (diff) | |
[1.2.X] Fixed #8217 -- Correctly sort files in FilePathFields on older Python versions. Thanks, bernd and davidb.
Backport from trunk (r14772).
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/forms/fields.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 4584a72c7a..46bda948bf 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -832,14 +832,14 @@ class FilePathField(ChoiceField): self.match_re = re.compile(self.match) if recursive: - for root, dirs, files in os.walk(self.path): + for root, dirs, files in sorted(os.walk(self.path)): for f in 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))) else: try: - for f in os.listdir(self.path): + for f in sorted(os.listdir(self.path)): full_file = os.path.join(self.path, f) if os.path.isfile(full_file) and (self.match is None or self.match_re.search(f)): self.choices.append((full_file, f)) |
