Skip to content

Instantly share code, notes, and snippets.

@niccolomineo
Last active August 3, 2024 13:19
Show Gist options
  • 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