Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!