Pythonanywhere: images with correct path do not load

1

I have a small application in Flask that uploads images with its description. The image is saved in a specific directory and the path is saved in a sqlite database next to the description. They are displayed in an html template.

When loading the page I can see that the description appears but the image does not load. When I inspect I can see that it corresponds to the correct address;

/home/mysite/mi_nombre/static/imagenes/Galeria/la_imagen.png

In my files I can see the image on that route. However, it does not load on the page.

Pythonanywhere is very clear about using absolute paths instead of relative ones. When trying to save the images using ./static/imagenes/Galeria/la_imagen.png it marks me error;   IOError: [Errno 2] No such file or directory: './static/imagenes/Galeria/la_imagen.png'

And the image does not go up.

If someone could guide me on why this behavior so I can understand it and see what direction to take to solve it, I would appreciate it very much.

    
asked by jke_online 17.07.2017 в 21:11
source

1 answer

0
# Prueba configurando esto en el settings #
## MEDIA_URL='/Direccion_media/' ##
## MEDIA_ROOT=os.path.join(BASE_DIR,"media") ##
*Ejemplo *,
### MEDIA_URL='/media/' ###
### MEDIA_ROOT=os.path.join(BASE_DIR,"media") ###
# Y luego agregalos en Static files de: Pythonanywhere:    #
   URL  --------------------------  Directory     
  /media/ ---------------------/home/Proyectos_yonatan/webyonatan/media/
    
answered by 13.09.2018 в 07:17