Last active
August 29, 2015 14:18
-
-
Save sthzg/f328da3da4cb8bc814cd to your computer and use it in GitHub Desktop.
Dynamically change storage location for Django's FileField and ImageField.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.files.storage import FileSystemStorage | |
def MyModel(models.Model): | |
# ... model stuff ... | |
some_file = models.FileField( | |
storage=FileSystemStorage( | |
location='/my/private/path/' | |
), | |
upload_to='downloads' | |
) | |
# files will be at /my/private/path/downloads/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment