Hi, I am new to fy.io, the background - I have a running Django app on fly.io and it appears that there is incorrect setup with media files - it seem not to work properly in production mode.
and it all comes to fly.toml file which looks like this:
app = "test"
[[statics]]
guest_path = '/code/static'
url_prefix = '/static/'
[[mounts]]
source = "media_data"
destination = "/app/media"
primary_region = 'waw'
console_command = '/code/manage.py shell'
[deploy]
release_command = 'python manage.py migrate --noinput'
[env]
PORT = '8000'
[http_service]
internal_port = 8000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']
[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
I deployed it successfully with settings like this and I did collect static which properly created media/uploads/ folder that contains pictures, also from admin ankle I see that pictures are being uploaded ( I even reuploaded) but no picture appearing on the site (on the volume it shows)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # You can change 'staticfiles' to any name
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
# media root and url
# media root is the path that stores the media files
# media url is the URL that points to the directory the media file uploaded is stored
# MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
MEDIA_ROOT = '/app/media'
This
‘missing an app name’
error started to appear when I erased the preceding app declaration in [brackets] - learnt that it is a table. When I try to keep both, it is impossible as I get an error about the duplication.
[app]
name = "test"
How can I overcome this? Any hint, advice greatly appreciated.
P.S. when I try to check the contents of the mounts the files appear:
drwxr-xr-x 2 root root 4096 Feb 27 09:38 uploads
root@e286de6a73d178:/code# cd /app/media/
root@e286de6a73d178:/app/media# cd uploads
root@e286de6a73d178:/app/media/uploads# ls -l
total 5904
-rw-r--r-- 1 root root 353970 Feb 27 09:38 OZ18_POzXkgF.jpg
-rw-r--r-- 1 root root 5687617 Feb 27 09:28 OZ1_qRN2etI.jpg
root@e286de6a73d178:/app/media/uploads#