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!
9 Replies
Project ID:
ee4f252f-387a-4b2c-999a-0af6f926854e
not sure why you are messing with postgres for media stuff?
Solution
but have a look at this template https://railway.app/template/AWUIv6
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.
please also review its code
specifically the urls.py
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})]
awesome
Thank you. That saved me a lot of time
haha vin wrote the code not me