Ticket #15651: filepath_sort.diff
File filepath_sort.diff, 1.8 KB (added by , 14 years ago) |
---|
-
django/db/models/fields/__init__.py
817 817 class FilePathField(Field): 818 818 description = _("File path") 819 819 820 def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, **kwargs):821 self.path, self.match, self.recursive = path, match, recursive820 def __init__(self, verbose_name=None, name=None, path='', match=None, recursive=False, sort=False, **kwargs): 821 self.path, self.match, self.recursive, self.sort = path, match, recursive, sort 822 822 kwargs['max_length'] = kwargs.get('max_length', 100) 823 823 Field.__init__(self, verbose_name, name, **kwargs) 824 824 -
django/forms/fields.py
880 880 class FilePathField(ChoiceField): 881 881 def __init__(self, path, match=None, recursive=False, required=True, 882 882 widget=None, label=None, initial=None, help_text=None, 883 *args, **kwargs):883 sort=False, *args, **kwargs): 884 884 self.path, self.match, self.recursive = path, match, recursive 885 885 super(FilePathField, self).__init__(choices=(), required=required, 886 886 widget=widget, label=label, initial=initial, help_text=help_text, … … 909 909 except OSError: 910 910 pass 911 911 912 if sort: 913 if callable(sort): 914 self.choices = sort(self, self.choices) 915 else: 916 self.choices.sort(key=lambda x: x[1]) 917 912 918 self.widget.choices = self.choices 913 919 914 920 class SplitDateTimeField(MultiValueField):