Load jQuery into Django

前端 未结 5 865
后悔当初
后悔当初 2021-01-14 05:56

I have a really basic question. I\'m trying to build some AJAX functionality into a Django project. I plan to use jQuery. Right now, I\'m just running the code locally th

5条回答
  •  有刺的猬
    2021-01-14 06:34

    Step1: put your jquery-2.0.3.js in the APP's "static" subfolder,like "books/static/jquery-2.0.3.js";

    Step2: config your urls.py, add the following line:

    r('^static/(?P.*)$','django.views.static.serve'),
    

    Step3: in your template file, use the js file as follows:

    
    

    That is all.

提交回复
热议问题