Comments (3)
from django-s3-storage.
Can I have the complete traceback, please? It looks like something in your code is expecting to be able to get a filesystem path. Since S3 doesn't support filesystem paths, that's not going to work. There's nothing in Django or django-s3-storage that mandates filesystem paths, so this is likely to be an issue in your code, or some 3rd party code. It's likely fixable, as S3 storage supports deletions just fine.
…
On Sun, 18 Jul 2021 at 13:03, sunjiali @.***> wrote: instance = Video.objects.get(id=video_id) instance.delete() ERROR: /storage.py", line 123, in path raise NotImplementedError("This backend doesn't support absolute paths.") NotImplementedError: This backend doesn't support absolute paths. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#125>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCE6YRGRBKCGFVR2FP3TYK7KHANCNFSM5ASCLWPA .
Here is complete
/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/fields/__init__.py:1361: RuntimeWarning: DateTimeField AmazonUser.date_joined received a naive datetime (2021-07-27 00:00:00) while time zone support is active. RuntimeWarning) /local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/fields/__init__.py:1361: RuntimeWarning: DateTimeField Comment.timestamp received a naive datetime (2021-07-27 00:00:00) while time zone support is active. RuntimeWarning) Admin dispatch Admin dispatch 2021-07-27T12:57:40.290409+00:00 zhytoolsset 361-140621172176640@dev-dsk-sunjiali-2c-1a5c57ee.us-west-2.amazon.com:0 [ERROR] log.py:230 log_response(): log: Internal Server Error: /center/video_delete/ Traceback (most recent call last): File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/video/helpers.py", line 46, in wrap return f(request, *args, **kwargs) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/myadmin/views.py", line 154, in video_delete instance.delete() File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/base.py", line 954, in delete return collector.delete() File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/deletion.py", line 436, in delete sender=model, instance=obj, using=self.using File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in send for receiver in self._live_receivers(sender) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in <listcomp> for receiver in self._live_receivers(sender) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/video/models.py", line 118, in auto_delete_file_on_delete if os.path.isfile(instance.file.path): File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/fields/files.py", line 59, in path return self.storage.path(self.name) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/files/storage.py", line 123, in path raise NotImplementedError("This backend doesn't support absolute paths.") NotImplementedError: This backend doesn't support absolute paths. Internal Server Error: /center/video_delete/ Traceback (most recent call last): File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/video/helpers.py", line 46, in wrap return f(request, *args, **kwargs) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/myadmin/views.py", line 154, in video_delete instance.delete() File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/base.py", line 954, in delete return collector.delete() File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/deletion.py", line 436, in delete sender=model, instance=obj, using=self.using File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in send for receiver in self._live_receivers(sender) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in <listcomp> for receiver in self._live_receivers(sender) File "/local/home/sunjiali/RDEBonesLambda/src/ZHYToolsSet/video/models.py", line 118, in auto_delete_file_on_delete if os.path.isfile(instance.file.path): File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/db/models/fields/files.py", line 59, in path return self.storage.path(self.name) File "/local/home/sunjiali/RDEBonesLambda/env/ZHYToolsSet-1.0/test-runtime/lib/python3.6/site-packages/django/core/files/storage.py", line 123, in path raise NotImplementedError("This backend doesn't support absolute paths.") NotImplementedError: This backend doesn't support absolute paths.
from django-s3-storage.
The problem is in ZHYToolsSet/video/models.py
where you do os.path.isfile(instance.file.path)
. You cannot access file.path
for django-s3-storage.
I'm not sure what this check acheives, as all S3 files are files. You should be able to simply:
from django.core.files.storage import default_storage
default_storage.delete(file.name)
from django-s3-storage.
Related Issues (20)
- Allow the storage to work in a Docker environment HOT 4
- I am defined AWS_S3_ENDPOINT_URL in settings but still use default S3 endpoint url HOT 2
- if I am using rotated s3 credentials how do I setup credentials HOT 2
- Is there a way to get upload progress? HOT 4
- support for large file upload HOT 2
- Setting similar to `AWS_S3_KEY_PREFIX` but instead prepend a dynamic param for each model's files HOT 2
- Caching with pre-signed url HOT 7
- sha1 or other hash before upload? HOT 6
- Public-read buckets and AWS_S3_BUCKET_AUTH HOT 4
- File is closed after s3 upload HOT 9
- Incompatibility issues with Django>=4.0 HOT 1
- Issue when upgrading to version 0.13.5 or higher HOT 4
- Huge Thanks HOT 2
- Update settings to define multiple S3 buckets HOT 1
- Document the `AWS_S3_MAX_POOL_CONNECTIONS` setting HOT 1
- Issues configuring AWS_S3_ENDPOINT_URL HOT 2
- Use Django's system check framework instead of log message HOT 1
- s3 bucket names being stored directly in migrations HOT 5
- Cannot open files in plain text mode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-s3-storage.