Search code examples
pythondjangopythonanywheredjango-media

Media files not showing on Debug False


I've just deployed a site with pythonanywhere, when I set to DEBUG mode to False, my media images dissapear, the path of my media folder is not found. I was asking myself what causes this issue and how I can resolve it ?

Here is how I configured my settings :

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

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

urls.py

urlpatterns = [
    ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Solution

  • Found it, with pythonanywhere I had to setup media on the static files handler like this :

    path : /media/

    directory : /home/<myusername>/<myproject>/media

    Then reload the domain name after setting DEBUG to False.