Giter Club home page Giter Club logo

Comments (3)

etianen avatar etianen commented on August 30, 2024

from django-s3-storage.

sunjiali avatar sunjiali commented on August 30, 2024

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.

etianen avatar etianen commented on August 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.