Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda