Fixed #5893 -- Added a flag to FilePathField to allow listing folders, in addition to regular files. Thank you to Brian Rosner, for encouraging me to first contribute to Django 4 years ago.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17925 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2012-04-22 14:44:08 +00:00
parent 83fc965171
commit 3c5ff9d703
6 changed files with 93 additions and 9 deletions

View file

@ -555,6 +555,23 @@ For each field, we describe the default widget used if you don't specify
A regular expression pattern; only files with names matching this expression
will be allowed as choices.
.. attribute:: allow_files
.. versionadded:: 1.5
Optional. Either ``True`` or ``False``. Default is ``True``. Specifies
whether files in the specified location should be included. Either this or
:attr:`allow_folders` must be ``True``.
.. attribute:: allow_folders
.. versionadded:: 1.5
Optional. Either ``True`` or ``False``. Default is ``False``. Specifies
whether folders in the specified location should be included. Either this or
:attr:`allow_files` must be ``True``.
``FloatField``
~~~~~~~~~~~~~~

View file

@ -691,6 +691,23 @@ directory on the filesystem. Has three special arguments, of which the first is
Optional. Either ``True`` or ``False``. Default is ``False``. Specifies
whether all subdirectories of :attr:`~FilePathField.path` should be included
.. attribute:: FilePathField.allow_files
.. versionadded:: 1.5
Optional. Either ``True`` or ``False``. Default is ``True``. Specifies
whether files in the specified location should be included. Either this or
:attr:`~FilePathField.allow_folders` must be ``True``.
.. attribute:: FilePathField.allow_folders
.. versionadded:: 1.5
Optional. Either ``True`` or ``False``. Default is ``False``. Specifies
whether folders in the specified location should be included. Either this
or :attr:`~FilePathField.allow_files` must be ``True``.
Of course, these arguments can be used together.
The one potential gotcha is that :attr:`~FilePathField.match` applies to the