I deployed my app to heroku: https://doggos-only.herokuapp.com/
The images on the Dog Images link work locally, but they do not work on the deployed version. The only useful error I'm getting is: cj_eOAaboi.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
My best guess is that it has something to do with the file path, but I'm not sure. I've tried looking around the web for a solution but have been unable to find one. Looking for any help, here is the repo: https://github.com/jpchato/doggos_only_project
I'm deploying from the deploy_branch in my repo.
That's because media files (Those files uploaded by the user) in heroku are not persistent, that means that after a certain time all the media will be erased.
I strongly suggest you to use a media CDN like cloudinary or amazon s3.
I wrote a post on how to setup a media CDN with cloudinary for free and you can access it right here
Django Tutorial: Set up Media files in Deployment for FREE
Related
I'm working on a small web application built with python and plotly-dash. Everything worked fine locally and so I deployed the code to Heroku. This also worked fine except for 2 out of 17 static images in the assets folder that won't get served after deployment. The error message is:
Failed to load resource: the server responded with a status of 404 (NOT FOUND)
The initial settings for plotly-dash were set to 'serve assets locally'. So I tried to serve them from an S3 bucket with the same result. These two images can't be found on the server.
One more piece of information. I saw that the file extension for both of these files was '.JPG' instead of '.jpg' for all the other files that are showed correctly. I saved them under XY.jpg but this didn't solve the problem either.
Any ideas what might be the problem here? I honestly run out of ideas. The code can be found here and the website is hosted here Click on 'Analyze' and 'Show me more details' to get to the problematic page.
I appreciate every input. Thanks inadvance.
I finally found the solution. Even though I changed the file extensions from 'JPG' to 'jpg' locally this change didn't make it to GitHub. I ended up converting the files to PNG format, adding and referencing them in the code and they finally showed up after deployment.
This is my first time ever on this platform, so please don't mind me if I am breaching any rules. I just finished building my first django project and I am using an amazon s3 bucket to serve media and static files. I have deployed the app onto heroku but static and media files are not being loaded. When I inspect the page, I see that it is throwing a 403 error. All the policies of my bucket have been set as prescribed in the documentation. below is a picture of my relevant setting.py
settings .py
I have a Blog created with Django 3.x. When I run the project on my local server then it works fine. So, I deployed my project to heroku and here is the link bblog-shovon.herokuapp.com/. Then the project was working fine. My project git link https://git.heroku.com/bblog-shovon.gitThen I created a post and then I gave it a thumbnail and finally everything was fine. But, After sometime when i revisit the site then every image were gone. I didn't found them. And when I tried to open the image on another tab then it shows this Error message screenshot. When I am writing this question then I created a new post and after publishing this this posts image is working. But, older image is not working.
Then, How can i fix this problem? Please help me!!
Heroku flushes the filesystem to the latest commit. So you will have to use third-party plugins such as AWSBucket, etc.
With Heroku the filesystem is not persisted so you will lose media files occasionally. Use S3 or some other provider to store your user-uploaded media (also your static files if you want, otherwise use whitenoise). Django-storages makes it very easy.
How can I edit the Google App Engine NGINX configuration?
There doesn't seem to be much support in the Google docs in regards to the NGINX configuration for apps running in the Google App Engine flexible environment.
My app is running fine, but I get this 413 error when I try and upload an audio file (.wav or .mp3).
413 Request Entity Too Large -- nginx
My app is running Django (python 3), with Cloud Postgres SQL and Cloud Storage enabled.
I researched the error, and it seems I can set a nginx.config file so that it includes "client_max_body_size 80M" - but like I said, there is no documentation regarding how to manually config NGINX on deploy.
Any suggestions?
You should be able to create a nginx-app.conf file in the same directory as your app.yaml file. There is an example of using the nginx configuration file in a Flex environment located here: https://github.com/GoogleCloudPlatform/getting-started-php/tree/master/4-auth .
This same file is referenced in Google's documentation here: https://cloud.google.com/appengine/docs/flexible/php/runtime#customizing_nginx
Once you have that file created, you should be able to add any property you need and then rebuild your project to see the changes take effect.
So upon contacting Google Support, the suggested solution for uploading files larger than 32MB is as follows:
"The way to circumvent App Engine's 32MB limit is to send the requests directly to Cloud Storage, for instance using the resumable upload process. You can still use App Engine to serve your app, but the clientside portion of the app would be the one handling the upload to Google Cloud Storage. For this you would have your application generate a signed URL which the client can use to gain access to your Cloud Storage bucket for the purpose of uploading an image."
I went with this solution. It saves money in the end.
I am new at django.
I upload images and it was working well when in development.
I use pythonanywhere for deploy my code.
The problem is I can upload image on admin but can't display unless reload the server.
I can show some code snippets you want.
I have no idea what the problem is
Also used Whitenoise to server media files. I added below the code I put to wsgi file in pythonanywhere
application = DjangoWhiteNoise(application)
application = WhiteNoise(
DjangoWhiteNoise(get_wsgi_application()),
root=settings.MEDIA_ROOT,
prefix='/media/',
)