Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
Django cannot serve uploaded media in production pythonanywhere

After succeed in development stage to serve the media uploaded (images) and view it in the pages, i am struggling in achieving this thing in production server and deployment seems too hard for me. using Pythoneverywhere platform i always get not found error:

2017-05-01 19:22:48,923 :Not Found: /media/I am title/31.jpeg

not only for this particular image, for every image i upload.

here is my settings file (some details are omitted not necessary here):

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

DEBUG = False

STATIC_URL = '/static/' # origin of permanent static files
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn") # temporarly loc

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")


STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
    #'/var/www/static/',
]

Here is my wsgi file mport os

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "flog.settings")

application = get_wsgi_application()
application = StaticFilesHandler(application)

It is just not working, I have tried to add this line ( Which is not recommended as in docs)

static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Still doesn't solve the problem. However, when i navigate through the platform i can find the media uploaded at the targeted folder !

Its been 2 days i am just trying to deploy the app and let it work i couldn't

here are platform configurations img

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I figured out that i have missed one of subdirectories to reach the directory i want ( as shown in picture )... finally !!

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda