Hi, there
I have an error when in my django DO app.
When I am reposting posts with screenshots I get this error in production:
NotImplementedError at /repost/577/ This backend doesn’t support absolute paths. Request Method: POST Request URL: https://www.sportsfamly.com/repost/577/
However the error is not there in development in local server.
All other post can be reposted - those that have text, videos, and JPEG photos, its only those that have screenshots that produce the error.
Let me also add that after I refresh the browser I discover that the post was reposted.
How can I resolved this?
I was thinking that if there is a way to escape the error it might resolve the issue as I mentioned that the post with the screenshot producing the error is reposted
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey Chris,
It sounds like you’re encountering a somewhat strange issue with your Django application when running on the DigitalOcean App Platform, especially concerning posts with screenshots. The error message you’re receiving,
NotImplementedError at /repost/577/ This backend doesn’t support absolute paths
, gives us a good starting point to troubleshoot.This error typically occurs when your application is trying to access a file or resource using an absolute file path, but the storage backend configured in your Django settings does not support this operation. In a production environment, especially on platforms like the DigitalOcean App Platform, your static and media files are often served differently than in a local development environment, which might be why you’re only encountering this issue in production.
Here are some things that you should start checking:
Check Your Storage Backend: First, verify what file storage backend you’re using in your production environment. If you’re using Django’s default file storage system, it works well with local filesystem paths. However, in production, especially with Kubernetes based systems like the App Platform, where the local storage is ephemeral, you should be using a different storage like DigitalOcean Spaces which require different configurations. Otherwise if you use the local ephemeral storage, every time you do a redeployment, your local files will be lost.
Review File Upload Handling: For files like screenshots that are uploaded by users, ensure your application handles these uploads correctly with your configured storage backend. If you’re using the DigitalOCean spaces, you should use the appropriate Django storage backend library, such as
django-storages
, and configure it to work with your service:Besides that, here are some debugging tips:
MEDIA_URL
andSTATIC_URL
to ensure they’re correctly set for your production environment.DEFAULT_FILE_STORAGE
setting in your Django settings.Since you mentioned that the post eventually gets reposted after refreshing, it indicates the operation might be succeeding, but the path resolution for the redirect or response is where the issue lies. This further emphasizes the need to ensure your application’s file path handling aligns with the capabilities of your storage backend.
I hope this helps you get to the bottom of the issue, let me know how it goes!
Best,
Bobby