运行本地服务器时,未知代码将添加到HTML模板中

时间:2017-10-03 03:38:32

标签: python django gulp dropzone.js

我正在构建个人资料图片功能,它工作正常,所以我离开了一段时间,可能是一个星期。我回到它并运行本地服务器,但是当我这样做时,控制台中出现了几行。但是源文件中不存在。

源文件:

<script type='text/javascript'>

Dropzone.options.myDropzone = {
    autoProcessQueue : false,
    paramName: 'uploaded_image',
    dictDefaultMessage: "Drag and drop files or click here to upload picture",

    init: function() {
        var submitButton = document.querySelector("#submitBtn")
        myDropzone = this;
        submitButton.addEventListener("click", function() {
            myDropzone.processQueue();
        });
        // Automatically overwrites file so the user can only upload one
        this.on("addedfile", function() {
            document.getElementById('submitBtn').style.visibility = "visible";
        });

        this.on('addedfile', function(){
            if (this.files[1]!=null){
                this.removeFile(this.files[0]);
            }
        });
    }
};
</script>
<!-- Modal -->
<div id="picModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <span class="close"></span>
    <form action="{% url 'profile_test' %}" method='POST' enctype="multipart/form-data" class="dropzone" id="my-dropzone">{% csrf_token %}
        <!-- submit button stays hidden by default, until user selects a picture -->
        <button id='submitBtn' type='submit' class='pic-submit-button' style='visibility: hidden;'> Submit </button>
        <input id='submit-all' type='file' name='uploaded_image'/>
            {{form}}
    </form>
  </div>

</div>

现在,当我运行服务器时,我看到的代码只有几行,并且它在创建模式的HTML中:

<!-- Modal -->
<div id="picModal" class="modal" style="display: block;">

  <!-- Modal content -->
  <div class="modal-content">
    <span class="close"></span>
    <form action="/api/profile_test/" method="POST" enctype="multipart/form-data" class="dropzone dz-clickable" id="my-dropzone"><input type="hidden" name="csrfmiddlewaretoken" value="WDMihPq0zDhDQGaWxSFYyvxjtmxUxsBMpAzcDqVxDGUZj11O8wtqbCfCie1m81Tf">
        <!-- submit button stays hidden by default, until user selects a picture -->
        <button id="submitBtn" type="submit" class="pic-submit-button" style="visibility: hidden;"> Submit </button>



       *****<input id="submit-all" type="file" name="uploaded_image">
            <label for="id_user">User:</label><select name="user" id="id_user">
  <option value="" selected="">---------</option>

  <option value="2">Brian</option>

  <option value="3">Charles</option>

</select>
<label for="id_img">Img:</label><input type="file" name="img" required="" id="id_img">
    <div class="dz-default dz-message"><span>Drag and drop files or click here to upload picture</span></div></form>
  </div>

</div>*****

我放置星星的最后一块代码是我不知道的代码。我克隆的Django项目是使用gulp,我和我的朋友聊过,他们说它可能与它有关,也许它正在用Dropzone.js做些什么?但是为什么它会在Django中注入一个列出用户的随机下拉菜单?我自己并没有使用gulp,因为我只是想开发这个功能,但这可能是一个错误。

1 个答案:

答案 0 :(得分:0)

可能是

{{form}}

造成了这个问题。