Skip to content Skip to sidebar Skip to footer

Correct Way To Save An Image In Admin And Showing It In A Template In Django

I am using MySql and Django. I need to select the image route stored in the database, I can't use the url property of an ImageField, It must be the route stored in the database. Fi

Solution 1:

I have found a partial solution, reading this Settings Media URL and after it redirected me to this Servinge files during development.

I'm using the last model, the one with the empty uploaded_to and just added the line that the docs recommend on the second link to the urls.py file, and also call the image on this way: ../../archivos/image.jpg but it says that the urls.py solution only works for development, not for serving it as a web page/application, so, someone knows how to make it work in a real server? without using DEBUG=true on settings?

Post a Comment for "Correct Way To Save An Image In Admin And Showing It In A Template In Django"