I have a new app that involves uploading images. I have tried all sorts of different combinations in fly.toml and my settings.py, but nothing has worked yet. Let’s pretend my app is named ‘fubar’. Here is what I am doing right now before my flyctl deploy:
There seem to be discrepancies between V1 and V2 with regard to the path. I am not altogether sure whether the [mounts] destination should be "/data", "/app/data", or "/fubar/data".
Perhaps my MEDIA_ROOT should simply be '/data/media' and should exclude the BASE_DIR?
Update: Thanks - Yes, I been setting the destination to the root, "/data", and my uploads are working and they persist. At this point my issue is Django itself, which is refusing to serve local media files. If I find a solution I will post it here.
I am stuck on this same issue. I have successfully deployed my django project with DEBUG = False, and although static is being served successfully from a volume located at /data, the same cannot be said for media.
When media is added to a model via the Admin portal, I can see that the file is being added to the storage volume, but when I then go to a template which tries to render this media (e.g. a user profile photo), all I get is a broken image icon. Can somebody please tell me how to serve media from a fly volume?
Ultimately I believe Django prevents local files that have been uploaded like this from showing up for security reasons I believe. Django collect static needs ran in order to show static files and since it is never ran to collect the new images it can’t display them. Which is really unfortunate because I want to do the same thing. I don’t want to have to store images in some far off land just to display them, it’s dumb.
Been a while, but I found a method that works for me.
Create a view that returns files from disk. Specifically I have a view/function that returns files from static/images/ and then I just pass the rest of the path/name into the function and it will return the image.