Fixed #24105 -- Called Storage.get_valid_name() when upload_to is callable

This commit is contained in:
Abhaya Agarwal 2015-05-03 09:40:24 +05:30 committed by Tim Graham
parent 7c7b855106
commit 9de9c24017
5 changed files with 39 additions and 6 deletions

View file

@ -88,9 +88,15 @@ instead).
.. method:: get_valid_name(name)
Returns a filename suitable for use with the underlying storage system. The
``name`` argument passed to this method is the original filename sent to the
server, after having any path information removed. Override this to customize
how non-standard characters are converted to safe filenames.
``name`` argument passed to this method is either the original filename sent to
the server or, if ``upload_to`` is a callable, the filename returned by that
method after any path information is removed. Override this to customize how
non-standard characters are converted to safe filenames.
.. versionchanged:: 1.9
In older versions, this method was not called when ``upload_to`` was a
callable.
The code provided on ``Storage`` retains only alpha-numeric characters, periods
and underscores from the original filename, removing everything else.

View file

@ -141,7 +141,9 @@ Email
File Storage
^^^^^^^^^^^^
* ...
* :meth:`Storage.get_valid_name()
<django.core.files.storage.Storage.get_valid_name>` is now called when
the :attr:`~django.db.models.FileField.upload_to` is a callable.
File Uploads
^^^^^^^^^^^^