我想将我的js文件导入到我的django模板中。但它没有导入,而css导入工作正常。
如果我尝试使用这些文件的直接http链接导入,那么它们工作正常但如果我将这些文件下载到myApp / static / js文件夹中,它们就无法正常工作。这是我的模板:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/FormStyle.css' %}">
**<script type = "text/javascript" src="{% static "js\validateForm.js" %}" ></script>**
**<script type = "text/javascript" src="{% static 'js/jquery.validate.min.js' %)"></script>**
<script src="http://cdn.jsdelivr.net/jquery.validation/1.13.1/additional-methods.js"></script>
<div class = "formArea">
<div class = "fileForm">
<form id = 'formFile' enctype="multipart/form-data" method="post"> {% csrf_token %}
<div class = "formFields">
<label for = "file"> {{ form.file.label }} </label>
{{ form.file }}
{{ form.file.errors }}
</div>
<div class = "formFields">
<input type="submit" value="Submit">
</div>
</form>
</div> </div> <script>
$(document).ready(function() {
$('#formFile').validate({
rules: {
'file': { required: true, extension: "txt|jpe?g|png|gif" } },
messages: {
'file': { required: 'Please Upload a File!',
extension: 'Only Image & txt Files are allowed!' }}
});
}); </script>