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
I figured out that i have missed one of subdirectories to reach the directory i want ( as shown in picture )... finally !!