From 914c72be2abb1c6dd860cb9279beaa66409ae1b2 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Sun, 20 Mar 2016 22:51:17 -0300 Subject: Fixed #26058 -- Delegated os.path bits of FileField's filename generation to the Storage. --- docs/ref/files/storage.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/ref') 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 `. + 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; -- cgit v1.3