diff options
| author | TildaDares <mathildaudufo@gmail.com> | 2026-03-29 22:02:10 +0100 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-29 14:52:25 -0400 |
| commit | 3f912ee4189602b4df121c0dc0428673fda5c253 (patch) | |
| tree | f696c3609f6de8520932a662c88f4918b5fba7fb /docs/ref/forms/fields.txt | |
| parent | 60a9c70496e5d7b971928ce3da5b47c8836a4def (diff) | |
Fixed #16429 -- Extracted set_choices() method from FilePathField.__init__().
Diffstat (limited to 'docs/ref/forms/fields.txt')
| -rw-r--r-- | docs/ref/forms/fields.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 085b36a0e5..8ddc5b9d79 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -724,6 +724,26 @@ For each field, we describe the default widget used if you don't specify whether folders in the specified location should be included. Either this or :attr:`allow_files` must be ``True``. + ``FilePathField`` has the following method: + + .. method:: set_choices() + + .. versionadded:: 6.1 + + Scans the directory at :attr:`path` and refreshes the field's + choices. This is called automatically during ``__init__()``, but it can + also be called explicitly to pick up files added to the directory + after the field was first instantiated (usually at server startup). For + example, call it in a form's ``__init__()`` to get fresh choices per + request:: + + class MyForm(forms.Form): + my_file = forms.FilePathField(path="/path/to/dir") + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["my_file"].set_choices() + ``FloatField`` -------------- |
