R
Railwayβ€’16mo ago
MIGHTY_MIDHUN

Django issue with images

I have a django app with debug set as False. I upload images from the UI and I cant see the uploaded images because the debug is set to false. So how do I resolve this issue. For example : if I upload image in django superadmin then also I cant view them
24 Replies
Percy
Percyβ€’16mo ago
Project ID: fd0bd18d-392d-4b0d-af5c-395356468583
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
fd0bd18d-392d-4b0d-af5c-395356468583
Brody
Brodyβ€’16mo ago
please reference this template https://railway.app/template/AWUIv6
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
Hi Brody. Can u provide further help on how to use this. There is no proper documenation regarding this
Brody
Brodyβ€’16mo ago
does the template not work?
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
I dont know how to connect this to my django app
Brody
Brodyβ€’16mo ago
please review the code of that template and make the needed changes in your code
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
Im very new to this and i dont know where the code for this template is
Brody
Brodyβ€’16mo ago
in the attached github repo, here is a direct link https://github.com/vfehring/django-volumes
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
thank you for providing this. But i cant figure out. how to connect this to my existing django deployed. should i change some environment variable ?
Brody
Brodyβ€’16mo ago
have you looked through all the code of the template?
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
I have
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
i added something like this to my django app
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
i dont know what i should provide for mount path
Brody
Brodyβ€’16mo ago
that is correct @Vin - could you provide some additional assistance when you are free
MantisInABox
MantisInABoxβ€’16mo ago
So, In your repo you want to focus on making your settings.py, urls.py files match the template repo settings and url files. You will also need to use the whitenoise package for serving your images. The template is there as a guide on how to structure your existing project to work with file uploads, or as a starting point for you to build your app on top of The mount point for your volume is perfect. Leave it that way I need to update the readme and the template docs today
Brody
Brodyβ€’16mo ago
thanks vin! πŸ™‚
MantisInABox
MantisInABoxβ€’16mo ago
No problem I know you have trouble with the words sometimes 🀣
Brody
Brodyβ€’16mo ago
its true
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
Thanks Vin for the help. actually I had to change my urls a little bit. #old urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) #new urlpatterns += [ re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT})] Also Vin. One more help would be highly appreciate. how do i run the collect static command.
Brody
Brodyβ€’16mo ago
use a railway.json file like the template does, this eliminates the need for a Procfile (once you have a railway.json you delete the Procfile) https://github.com/vfehring/django-volumes/blob/master/railway.json#L7
MantisInABox
MantisInABoxβ€’16mo ago
If you look in the github associated with the template, you will see the command ^^
MIGHTY_MIDHUN
MIGHTY_MIDHUNβ€’16mo ago
Thank you very much for the help Brody. So as per my understanding the whatever we have provided within the startCommand in railway.json will be automatically executed whenever we update the repo. Am i right ?
MantisInABox
MantisInABoxβ€’16mo ago
This is correct. The railway.json command is everything that you need to to to start running your app
Want results from more Discord servers?
Add your server