#28264: forms.FilePathField does not return sorted subdirectories in formfield
--------------------------------------+------------------------------------
Reporter: Jean-Marie Thomas | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: FilePathField | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):
* stage: Unreviewed => Accepted
* type: Uncategorized => Cleanup/optimization
* needs_tests: 0 => 1
Old description:
> In the code :
>
> for root, dirs, files in sorted(os.walk(self.path)):
> if self.allow_files:
> # here, files are not sorted
> 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)))
> if self.allow_folders:
> # and here, dirs are not sorted
> for f in dirs:
> if f == '__pycache__':
New description:
In the code :
{{{
for root, dirs, files in sorted(os.walk(self.path)):
if self.allow_files:
# here, files are not sorted
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)))
if self.allow_folders:
# and here, dirs are not sorted
for f in dirs:
if f == '__pycache__':
}}}
--
Comment:
Could you also add a test and send a pull request on GitHub?
--
Ticket URL: <https://code.djangoproject.com/ticket/28264#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.e61944f1fd886e86abe61bbb6535aa6d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.