Javascript with Django?

前端 未结 8 1270
日久生厌
日久生厌 2021-02-06 19:20

I know this has been asked before, but I\'m having a hard time setting up JS on my Django web app, even though I\'m reading the documentation.

I\'m running the Django de

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 19:21

    The error 404 occurs because MEDIA_ROOT requires absolute path, not relative. The server is trying to access /media in your filesystem, which is obviously not what you want.

    Try this instead:

    import os
    PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
    MEDIA_ROOT = os.path.join(PROJECT_PATH, 'site_media')
    MEDIA_URL = '/media/'
    

提交回复
热议问题