如何加载django提供的jquery到你的模板中



如何加载Django提供的jquery而不是重新下载。

{% load admin/static %}
<script src="{% static 'js/jquery.js' %}"></script>

代替:

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>


在今天的Django 3.2中,解决方案是:
<script src="{% static "admin/js/vendor/jquery/jquery.min.js" %}"></script>

源https://gist.github.com/magopian/4078269

最新更新