Ticket #8217: FilePathField-sorted.diff

File FilePathField-sorted.diff, 1.0 KB (added by bernd, 16 years ago)
  • django/forms/fields.py

     
    782782        if self.match is not None:
    783783            self.match_re = re.compile(self.match)
    784784        if recursive:
    785             for root, dirs, files in os.walk(self.path):
     785            for root, dirs, files in sorted(os.walk(self.path)):
    786786                for f in files:
    787787                    if self.match is None or self.match_re.search(f):
    788788                        f = os.path.join(root, f)
    789789                        self.choices.append((f, f.replace(path, "", 1)))
    790790        else:
    791791            try:
    792                 for f in os.listdir(self.path):
     792                for f in sorted(os.listdir(self.path)):
    793793                    full_file = os.path.join(self.path, f)
    794794                    if os.path.isfile(full_file) and (self.match is None or self.match_re.search(f)):
    795795                        self.choices.append((full_file, f))
Back to Top