Search code examples
pythondjangodeploymentmediapythonanywhere

In django, what is correct setup for media deployment on python anywhere


I am trying to deploy my django app on python anywhere, but I believe media_urls or media_root may be set incorrectly. I also spent time trying to figure out how to print all valid urls on django, but nothing work for me on this link. Django : How can I see a list of urlpatterns?.

I received a "ModuleNotFoundError: No module named 'django.core.urlresolvers'"

from .base import *

DEBUG = False

ALLOWED_HOSTS = ["*"]

MEDIA_ROOT = os.path.join(BASE_DIR, "images")
MEDIA_URL = '/snapcapsule/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

Picture of me setting the path on pythonanywhere Picture to get request for image

Answer

Answer


Solution

  • Your static file mapping for images is at at /images, but you're accessing the image from /snapcapsule/images. Either change your media_url or your static file mapping so that they match.