Django media with volume

Hi, Im trying to link railway volume with my django deployment. Does anyone able to make it work? Point me out if I'm not using the correct setup. Thanks
11 Replies
Percy
Percy11mo ago
Project ID: e4929780-2d35-4751-a60d-5216ec1f7378
_bluellama
_bluellama11mo ago
e4929780-2d35-4751-a60d-5216ec1f7378
Brody
Brody11mo ago
1. mount to /app/media 2. do not define any variables for the volume yourself, please remove them 3. have a look at this template https://railway.app/template/AWUIv6
_bluellama
_bluellama11mo ago
Done 1 and 2. And change my setting.py according to 3 for media_root . But no luck so far. Not sure where i'm missing
_bluellama
_bluellama11mo ago
After i remove compress in model save function. i can upload just fine. Not sure why though....
Brody
Brody11mo ago
bug in the compressor code?
_bluellama
_bluellama10mo ago
Nvm that one is separate issue. I saw the template is using serve view and it is not recommended for for production. https://docs.djangoproject.com/en/4.2/ref/views/.
Django Project
Django
The web framework for perfectionists with deadlines.
_bluellama
_bluellama10mo ago
Any other way i can serve the media easily? Probably need to expose in nginx the media folder or smething like that. I'm really bad at this deployment/devops cryingman
Brody
Brody10mo ago
thats correct, it is not recommended for production, but (and i really mean no offense) if you have to ask how to do it properly, the serve view is likely more then sufficent for you, but you do have the right idea, you would need nginx or caddy to serve the files from the media folder and then have it proxy all other traffic to django
MantisInABox
MantisInABox10mo ago
Yes, the way the template is setup currently, is not meant for production use. Small scale production it is fine, but serving 10’s of thousands of users, definitely not. Maybe even thousands. The template is just a guide on getting things working for testing. I plan on setting up another template soon for properly serving in production environments
_bluellama
_bluellama10mo ago
Thanks @Brody and @Vin.