mirror of
https://github.com/django/django.git
synced 2025-03-11 18:02:35 +00:00
Hidden __pycache__ dirs for FilePathField. Refs #17393.
This will be tested as soon as tests will run under Python 3. Patch taken from Vinay Sajip's Python 3 branch.
This commit is contained in:
parent
aa757ac22d
commit
eb0140bddc
@ -932,12 +932,16 @@ class FilePathField(ChoiceField):
|
|||||||
self.choices.append((f, f.replace(path, "", 1)))
|
self.choices.append((f, f.replace(path, "", 1)))
|
||||||
if self.allow_folders:
|
if self.allow_folders:
|
||||||
for f in dirs:
|
for f in dirs:
|
||||||
|
if f == '__pycache__':
|
||||||
|
continue
|
||||||
if self.match is None or self.match_re.search(f):
|
if self.match is None or self.match_re.search(f):
|
||||||
f = os.path.join(root, f)
|
f = os.path.join(root, f)
|
||||||
self.choices.append((f, f.replace(path, "", 1)))
|
self.choices.append((f, f.replace(path, "", 1)))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
for f in sorted(os.listdir(self.path)):
|
for f in sorted(os.listdir(self.path)):
|
||||||
|
if f == '__pycache__':
|
||||||
|
continue
|
||||||
full_file = os.path.join(self.path, f)
|
full_file = os.path.join(self.path, f)
|
||||||
if (((self.allow_files and os.path.isfile(full_file)) or
|
if (((self.allow_files and os.path.isfile(full_file)) or
|
||||||
(self.allow_folders and os.path.isdir(full_file))) and
|
(self.allow_folders and os.path.isdir(full_file))) and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user