user1447443
user1447443

Reputation: 53

django-storages, how to override back to django's local file storage

I have setup django with django-storages and set the default file storage to s3boto

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

however I want to store one type of model filefield locally in '/media', whats the best way to revert back to django's original default file storage, I have tried implementing FileSystemStorage but Im getting a SuspiciousOperation error

do i need to write my own custom storage class?

Upvotes: 1

Views: 1946

Answers (1)

FileField accepts a storage parameter.

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.storage

from django.core.files.storage import FileSystemStorage

fs = FileSystemStorage(location='/media/photos')

class Car(models.Model):
    ...
    photo = models.FileField(storage=fs)

Upvotes: 1

Related Questions