Skip to content

Instantly share code, notes, and snippets.

@niccolomineo
Last active January 15, 2023 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niccolomineo/2b034f97571ec8106ea41248b4e5156e to your computer and use it in GitHub Desktop.
Save niccolomineo/2b034f97571ec8106ea41248b4e5156e to your computer and use it in GitHub Desktop.
A file system storage with file overwriting capabilities
"""Django storages."""
from django.core.files.storage import FileSystemStorage
class FileSystemOverwriteStorage(FileSystemStorage):
"""A file system storage with file overwriting capabilities."""
def get_available_name(self, name, max_length=None):
"""Return the available name."""
self.delete(name)
return super().get_available_name(name, max_length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment