Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

index.html not found in media_root #54

Open
eugene123tw opened this issue Mar 29, 2017 · 0 comments
Open

index.html not found in media_root #54

eugene123tw opened this issue Mar 29, 2017 · 0 comments

Comments

@eugene123tw
Copy link

I followed the tutorial to set the MEDIA_ROOT.
My settings at below:

# wsgi.py 
import os

from django.core.wsgi import get_wsgi_application
from dj_static import Cling, MediaCling

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
application = Cling(MediaCling(get_wsgi_application()))
#settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
ALLOWED_HOSTS = ['*']
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static_root')
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static', 'static_dirs'),
)

MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media_root')
MEIDA_URL = '/media/'

My error message :
[WinError 2] The system cannot find the file specified : 'C:/myapps/static/media_root/index.html'

And my localhost:8000 directs me to 404 Not Found

I found this code in static.py. I think is somehow related to the issue.

class Cling(object):

    """A stupidly simple way to serve static content via WSGI.

    Serve the file of the same path as PATH_INFO in self.datadir.

    Look up the Content-type in self.content_types by extension
    or use 'text/plain' if the extension is not found.

    Serve up the contents of the file or delegate to self.not_found.
    """

    block_size = 16 * 4096
    index_file = 'index.html'
    not_found = StatusApp('404 Not Found')
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant