R
Railway12mo ago
Jackson

Django (Wagtail) Media Files

Id: ee4f252f-387a-4b2c-999a-0af6f926854e I am having trouble setting up a volume to serve the media files uploaded by a Wagtail admin user. The PostgreSQL database template comes with a volume 'pgdata' by default. I tried attaching another volume to my production service called 'media' with path '/media/' as well as '/app/media/'. Neither worked. I even tried setting the MEDIA_URL to the database's PGDATA variable which is 'var/lib/postgresql/pgdata/' I know I am missing something. Thanks!
Solution:
but have a look at this template https://railway.app/template/AWUIv6
Jump to solution
9 Replies
Percy
Percy12mo ago
Project ID: ee4f252f-387a-4b2c-999a-0af6f926854e
Brody
Brody12mo ago
not sure why you are messing with postgres for media stuff?
Solution
Brody
Brody12mo ago
but have a look at this template https://railway.app/template/AWUIv6
Jackson
JacksonOP12mo ago
I tried it after the server's attached volume didn't work. Thought maybe the volume attached to the database was the place. I've already visited that resource. I'll try the 'Troubleshooting' section though. I have yet to try making a new directory.
Brody
Brody12mo ago
please also review its code specifically the urls.py
Jackson
JacksonOP12mo ago
Thanks. I wouldn't have thought to look at the repo. I'm deploying with new settings and urls now That was it! In settings set MEDIA_URL to RAILWAY_VOLUME_MOUNT_PATH and in urls.py set urlpatterns += [ re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT})]
Brody
Brody12mo ago
awesome
Jackson
JacksonOP12mo ago
Thank you. That saved me a lot of time
Brody
Brody12mo ago
haha vin wrote the code not me
Want results from more Discord servers?
Add your server