Media files don't show on Django app in production mode on mounted device

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# 

Where are you seeing this message?

The closest error message we would produce would be:

the config for your app is missing an app name, add an app field to the fly.toml file or specify with the -a flag

This message would be produced by commands like fly deploy. You wouldn’t see it in your logs or on your server. I suspect that that message is being produced by your application.

Thank you for the answer, it appears

 flyctl volumes list
Error: the config for your app is missing an app name, add an app field to the fly.toml file or specify with the -a flag

I also had it on deploy, but after I modified fly.toml but after successful deployment it reappeared again and media still not showing

This is indeed the correct syntax. Does the message appear when this is present? Are you running flyctl volumes list from the same directory in which the fly.toml exists?

1 Like

Yes, it helped and I have

mount media_data

so the question still is why media not appear?