I'm working on a Django app (DRF), but I'm a JS engineer so this is all new to me.
I have this in my models.py, outside of any actual models:
storage = S3Storage(aws_s3_bucket_name=settings.DOCUMENTS_BUCKET)
upload_location = 'recordings/'
and this is a field it is used in, inside one of the models:
zip_file = models.FileField(
upload_to=upload_location, storage=storage, null=True)
This works OK in production. However, I want to be able to test it locally, add those zip files when developing locally. So I've added this for storage and upload_location:
if settings.DEBUG:
storage = FileSystemStorage(location='/')
upload_location = ''
Then, when I try saving a file from admin on localhost, I get the following error:
[Errno 13] Permission denied: '/my-file.zip'
If I got it right, the app cannot just create that location somewhere on my file system. Maybe I'm wrong. How can I solve this?
/refers to the root directly of your filesystem. Are you sure that's where you want to store things? SurelyMEDIA_ROOTwould be a better place./refers to the root of the project that's currently running and I've changed those permissions. Modified the path now and it's fine.Thanks!