l have deployed my app to Heroku but some images are no longer being loaded.
For example, people's profile pics are not showing up, but if that person re-uploads one it will be visible. However, when they log out/in again, the picture is no longer there.
What would cause this type of behavior and how can I fix it? Locally everything works fine.
I found this information on http://www.gettingstartedwithdjango.com/introduction-and-launch.html#what-heroku-does-every-time-you-push-to-them-is
What Heroku does every time you push to them is:
Creates a new app space with its own virtual machine, virtual environment, and packages installed through pip.
Swaps the subdomain over to the new location.
Deletes the old app space.
What this means is that anything added to the app that is not in Git, won’t last between pushes. Even more, this exact same process happens once every 24 hours anyway, so uploaded files have to go somewhere other than Heroku.
You might look into this as a possible source of your issue.
Here is an answer from the pythonanywhere blog which may answer your question.
Basically, when going into production, setting (in settings.py) DEBUG = False raises a security lock on the file tampering with the image urls.
So basically a file path change is in order for the MEDIA_ROOT from development to production.
More information given on the blog here.
Hope this helps!
Related
I added a few books on heroku data. Every model is displayed on heroku app site with its image. My models have the field "image". I take these images from my PC folder and when I open this app after 2-3 hours the book images dissapear. I think it's because I turn off a PC, where I took these images. How do I have to do it correctly that these images don't dissapear?
I think it's because I turn off a PC, where I took these images
This probably is not it, because Heroku doesn't have access to the files on your computer.
When you upload a file to the Django admin, it looks at the DEFAULT_FILE_STORAGE settings configuration to determine how to store that file. By default, it uses django.core.files.storage.FileSystemStorage, which means that it is writing those uploaded files to the dyno's filesystem at the location defined by MEDIA_ROOT.
The issue is, dynos are ephemeral, and they can be destroyed, restarted, and moved without any warning, which replaces your filesystem. This means that those uploaded files are just deleted without a trace, but the ImageField reference still thinks they are there.
The solution to this issue is to update the project's DEFAULT_FILE_STORAGE to use something permanent, such as an s3-compatible object store. In Heroku & Django land, a common solution is to use django-storages alongside Heroku's Bucketeer add-on. This solution uploads your files to a persistent data store that survives dyno restarts, instead of writing to the dyno file system which gets deleted frequently.
I know that this can be daunting, so I wrote up this article with a pretty good write-up of the Heroku + Bucketeer process.
I've got a Django site which uses the "django-machina" forum software, which in its latest incarnation apparently uses Bootstrap4 styling.
After installing the package according to directions, it looks beautiful on my development box. But, when I deploy exactly the same software on production, Bootstrap obviously isn't running because nothing is properly styled.
There are no 404's and no console messages. *(Yes, I remembered to run manage.py collectstatic ...) There are some stylesheets complaints from Firefox but they're identical in both cases. But ... the display is not!
Can anyone suggest what I might do in order to solve this problem? I'm stumped!
Well, once again I answered my own question!
I correctly guessed that, since I was maintaining the remote site from my own box using rsync, there might be some garbage left over on the remote side that wasn't being swept-up. (I can't use rsync --delete for fear of smashing directories that contain images and uploaded materials.) I guess it would probably be smarter for me to start using an external repo so that git can do for me what it's designed to do ...
But anyway, when I deleted selected directories containing the central and most-often updated directories, then used rsync to replace them with clean copies, the interference went away and production now looks correct.
Before anyone can tell me how to put the other question solved? Hello local site works well, but in Heroku the picture is not displayed anymore
In production the static files are at the same level as the folder of the images according to the logging that's what breaks the problem thank you for your help.
the file upload images is img_url
Heroku has an ephemeral filesystem. Each running dyno is an independent container. So if you store a file on disk, it will be lost (and not recoverable) once the dyno restarts (which happens whenever the app is deployed, or once every 24 hours).
You need to store your files on a dedicated storage system, such as Amazon S3.
See https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted
Since I updated my production setup to Wagtail 1.11 I cannot load the admin page for images. Visiting /admin/images/ results in a 502 error. In my development setup I don't have the same problem
This is the result of a crash of the runner. The memory and CPU usage of the runners gets too high for the server to handle at which point they are killed. (Seen in top and restarts are shown in the logs)
This seems to be the same as https://github.com/wagtail/wagtail/issues/3575, but Wand is not used and no GIF images are uploaded to the system so this is not the cause. The following seemingly relevant python packages are used:
Django==1.11.3
gunicorn==19.7.1
Pillow==4.2.1
wagtail==1.11.1
Willow==0.4
The project is running on a fully updated Ubuntu 16.04 machine.
Does anyone have a suggestion of what can fix this bug?
Try removing some of the more recent or larger images and reloading the page. The problem could be the result of a corrupt or malicious image.
The easiest way to diagnose if this is the problem is to:
Move all images from the media/original_images folder to a backup folder.
Access the /admin/images page. If this was the problem the page should now load again.
Note all images that now do not have a thumbnail; these are the pictures crashing the application.
Move all picture except for the ones noted back into the media/original_images folder.
Except for the picture crashing your system, everything should now work similar to what it did before.
Am working on an aldryn-newsblog. it works well on my local host.
once i push the blog to heroku, thats when i get a problem.
Every time i add a new article, the article publishes very well with no problem. but after some time,say 20 mins the featured image just disappears. This forces me to edit the article again so as to add the image afresh.
image showing my file missing once i try to edit my article
What might be the problem? kindly assist.
Heroku uses ephemeral file system (files may be written to the app’s “tmp/” directory, but can be discarded by the system at any time)
Use a cloud storage service instead, see https://devcenter.heroku.com/articles/s3
Heroku docs: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem