Javascript with Django?

前端 未结 8 1268
日久生厌
日久生厌 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:46

    But does that /media/ global directory exist? And have you placed in there a scripts subdirectories with the scripts you want to serve from there? What about the /scripts/... url from which you want to serve JQuery.js -- that doesn't seem to be served anywhere from your urls.py. If you (for whatever reason) want to serve scripts (or any other statically served file) from several different URL paths, all of those URL paths need to be matched in urls.py with the static-serving -- or else, do the normal things and serve them all from the /media/... root URL, and map that media root to the dir where you actually keep these files (in their respective subdirs, typically).

    Django's docs about static serving (for development only, since it's documented as

    Using this method is inefficient and insecure. Do not use this in a production setting. Use this only for development.

    so beware!-) seems pretty clear to me.

提交回复
热议问题