core.files.storage.Storage.get_available_name()

get_available_name(name, max_length=None) [source]

Returns a filename based on the name parameter that’s free and available for new content to be written to on the target storage system.

The length of the filename will not exceed max_length, if provided. If a free unique filename cannot be found, a SuspiciousFileOperation exception will be raised.

If a file with name already exists, an underscore plus a random 7 character alphanumeric string is appended to the filename before the extension.

doc_Django
2016-10-09 18:34:47
Comments
Leave a Comment

Please login to continue.