diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-05-16 17:56:56 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-05-16 23:15:49 +0200 |
| commit | eb0140bddca4d25be2bf02144f43b1b12b0cbed3 (patch) | |
| tree | bf786f71a12dcfb9c51378813c07356afa004170 | |
| parent | aa757ac22de3e657df49086cf01a26f6c73b8dfb (diff) | |
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.
| -rw-r--r-- | django/forms/fields.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 61137f55c1..53250cc8a9 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -932,12 +932,16 @@ class FilePathField(ChoiceField): self.choices.append((f, f.replace(path, "", 1))) if self.allow_folders: for f in dirs: + if f == '__pycache__': + continue 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 sorted(os.listdir(self.path)): + if f == '__pycache__': + continue full_file = os.path.join(self.path, f) if (((self.allow_files and os.path.isfile(full_file)) or (self.allow_folders and os.path.isdir(full_file))) and |
