class FilePathField(**kwargs) [source]
- Default widget:
Select - Empty value:
None - Normalizes to: A unicode object
- Validates that the selected choice exists in the list of choices.
- Error message keys:
required,invalid_choice
The field allows choosing from files inside a certain directory. It takes five extra arguments; only path is required:
-
path -
The absolute path to the directory whose contents you want listed. This directory must exist.
-
recursive -
If
False(the default) only the direct contents ofpathwill be offered as choices. IfTrue, the directory will be descended into recursively and all descendants will be listed as choices.
-
match -
A regular expression pattern; only files with names matching this expression will be allowed as choices.
-
allow_files -
Optional. Either
TrueorFalse. Default isTrue. Specifies whether files in the specified location should be included. Either this orallow_foldersmust beTrue.
-
allow_folders -
Optional. Either
TrueorFalse. Default isFalse. Specifies whether folders in the specified location should be included. Either this orallow_filesmust beTrue.
Please login to continue.