您完全知道这看起来像重复的,但事实并非如此,其他问题的修复程序并未解决此问题。我正在尝试在django表单中添加日期选择器,但是我以前从未使用过jquery,但是现在看来我必须这样做,但无法使其工作。我正在尝试遵循本指南https://simpleisbetterthancomplex.com/tutorial/2019/01/03/how-to-use-date-picker-with-django.html#fengyuan-chens-datepicker,并尝试使用fengyuanchen_datepicker。我根本无法使用它,我认为这是由于页面顶部的cdn链接。 这是标题:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Project Portal+ :: sidev</title>
<link rel="shortcut icon" href="{% static 'project_portal/images/favicon.ico' type='image/x-icon' %}">
<link rel="stylesheet" href="{% static 'project_portal/css/project_portal.css' %}">
<link type="application/javascript" href="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/i18n/datepicker.en-GB.min.js">
<script src="jquery-3.4.1.min.js"></script>
</head>
这是我正在尝试使其运行的html:
<!DOCTYPE html>
{% extends "project_portal/base.html" %}
{% block detail %}
<div class="project_setup">
<h1>Project Setup</h1>
<form class="update" method="POST">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" class="btn" value="Submit">
<a href="{% url 'project-list' %}">Cancel</a>
</form>
</div>
<script>
$(function () {
$("#id_date").datepicker({
format: 'dd/mm/yyyy',
});
});
</script>
{% endblock %}
我假设“ $”是一个jQuery的东西,我个人不愿意使用它,因为这样做确实很肿,但是由于引导程序已关闭,我目前找不到另一种方法限制,因为它弄乱了我当前的CSS。我该怎么做才能使它正常工作。