diff options
| author | Cristiano <cristianocca@hotmail.com> | 2016-03-20 22:51:17 -0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-30 17:22:40 -0400 |
| commit | 914c72be2abb1c6dd860cb9279beaa66409ae1b2 (patch) | |
| tree | f0b806a902e984e13a048c9c082afb1fdefac2df /docs/ref/files | |
| parent | 8dcf352c031f18011e06b4e099ca44b8fa7ba4c2 (diff) | |
Fixed #26058 -- Delegated os.path bits of FileField's filename generation to the Storage.
Diffstat (limited to 'docs/ref/files')
| -rw-r--r-- | docs/ref/files/storage.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt index be197f7210..dd0670137c 100644 --- a/docs/ref/files/storage.txt +++ b/docs/ref/files/storage.txt @@ -164,6 +164,21 @@ The ``Storage`` class Returns a filename based on the ``name`` parameter that's suitable for use on the target storage system. + .. method:: generate_filename(filename) + + .. versionadded:: 1.10 + + Validates the ``filename`` by calling :attr:`get_valid_name()` and + returns a filename to be passed to the :meth:`save` method. + + The ``filename`` argument may include a path as returned by + :attr:`FileField.upload_to <django.db.models.FileField.upload_to>`. + In that case, the path won't be passed to :attr:`get_valid_name()` but + will be prepended back to the resulting name. + + The default implementation uses :mod:`os.path` operations. Override + this method if that's not appropriate for your storage. + .. method:: listdir(path) Lists the contents of the specified path, returning a 2-tuple of lists; |
